使用path,getrandomfilename在temp中创建文件夹? [英] Create folder in temp with path, getrandomfilename?

查看:107
本文介绍了使用path,getrandomfilename在temp中创建文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用path.getrandomfilename在Temp中创建文件夹?如果你这样做,谢谢你试着帮助我! :D



我尝试过:



研究,但没有作品。也许使用这段代码:

Is it possible to create a folder in Temp with path.getrandomfilename? Thanks for trying to help me out if you do! :D

What I have tried:

Research, but nothing works. Maybe use this code:

dim path as String = "D:\Mahesh"
IF Not Directory.Exists(path) then
Directory.CreateDirectory(path)
End IF

并将其更改为在Temp中创建一个文件夹,使用Path.GetRandomFileName?

and change it to make a folder in Temp, with Path.GetRandomFileName?

推荐答案

您可以在if之前执行此类操作条件。



调用以下方法获取路径,然后检查路径是否存在,如果没有创建目录。



public string GetTemporaryDirectory()

{

string tempDirectory = Path.Combine(Path.GetTempPath(),Path.GetRandomFileName());

Directory.CreateDirectory(tempDirectory);

返回tempDirectory;

}



请将代码转换为VB net
You can do something like this before your if condition.

Call the below method to get the path and then check if the path exists, if not create the directory.

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

Please convert the code to VB net


这篇关于使用path,getrandomfilename在temp中创建文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆