private readonly string testPath = Path.Combine(Path.GetTempPath(), "TestSerializer.xml");Create a temporary file name in the temporary directory but with a specified extension:
public static class PathClassExtender { public static string GetTempFileName(string newExtension) { string res = Path.ChangeExtension(Path.GetTempFileName(), newExtension); return res; } }Sample usage:
string filename = PathClassExtender.GetTempFileName(".bat");filename will get set to something like
"C:\Users\RB\AppData\Local\Temp\tmp517F.bat"
No comments:
Post a Comment