Skip to content

Fix: use Path.GetTempPath() for temporary file in Serialize#22

Open
HashidaTKS wants to merge 1 commit intomasterfrom
fix/tempfile-path
Open

Fix: use Path.GetTempPath() for temporary file in Serialize#22
HashidaTKS wants to merge 1 commit intomasterfrom
fix/tempfile-path

Conversation

@HashidaTKS
Copy link
Copy Markdown
Owner

問題点

XmlSerializerWrapper.Serialize() 内のテンポラリファイルパスとして .\{random} という相対パスを使用していた。

これはプロセスの作業ディレクトリに依存するため、アプリケーションの起動方法や配置環境によって予期しない場所にファイルが生成される可能性があった。また権限の問題でファイル生成に失敗するリスクもあった。

改善内容

  • $@".\{Path.GetRandomFileName()}"Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()) に変更
  • OS が保証する書き込み可能なテンポラリディレクトリを使用するよう修正

Test plan

  • シリアライズ時にテンポラリファイルがシステムの temp ディレクトリに作成されることを確認
  • シリアライズ完了後にテンポラリファイルが削除されることを確認

🤖 Generated with Claude Code

.\{random} depends on the process working directory, which varies by
deployment environment and can be unpredictable. Use the OS temp directory
via Path.GetTempPath() to ensure the file is always written to a known,
writable location regardless of where the application is launched from.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant