由网友(不浪漫罪名)分享简介:什么是获得在Windows临时目录名的最好方法是什么?我看到,我可以使用 GetTempPath 和 GetTempFileName 来创建一个临时文件,但没有任何等同于Linux的/ BSD mkdtemp 函数用于创建一个临时目录?What's the best way to get a temp dire...
什么是获得在Windows临时目录名的最好方法是什么?我看到,我可以使用 GetTempPath
和 GetTempFileName
来创建一个临时文件,但没有任何等同于Linux的/ BSD mkdtemp
函数用于创建一个临时目录?
What's the best way to get a temp directory name in Windows? I see that I can use GetTempPath
and GetTempFileName
to create a temporary file, but is there any equivalent to the Linux / BSD mkdtemp
function for creating a temporary directory?
推荐答案
没有,没有等同于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;
}
相关推荐
最新文章