且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Windows中创建一个临时目录?

更新时间:2023-11-23 10:09:28

没有,没有等同于mkdtemp。***的办法是使用 GetTempPath 和GetRandomFileName.

No, there is no equivalent to mkdtemp. The best option is to use a combination of GetTempPath and GetRandomFileName.

您将需要code与此类似:

You would need code similar to this:

public string GetTemporaryDirectory()
{
   string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
   Directory.CreateDirectory(tempDirectory);
   return tempDirectory;
}