Click here to Skip to main content
15,881,044 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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
and change it to make a folder in Temp, with Path.GetRandomFileName?
Posted
Updated 16-Jul-17 17:23pm
Comments
Jim Meadors 16-Jul-17 22:31pm    
That is what I would try...

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900