How can I create a temp file with a specific extension with .NET?

后端 未结 17 2022
北恋
北恋 2020-11-28 01:49

I need to generate a unique temporary file with a .csv extension.

What I do right now is

string filename = System.IO.Path.GetTempFileName().Replace(         


        
17条回答
  •  [愿得一人]
    2020-11-28 02:21

    Easy Function in C#:

    public static string GetTempFileName(string extension = "csv")
    {
        return Path.ChangeExtension(Path.GetTempFileName(), extension);
    }
    

提交回复
热议问题