In other words, i have temp folder where i store my extracted files. How do i create a folder in that temp folder so that all files are extracted or unzipped in this folder, which is inside the temp folder?
A:
Simple
Directory.CreateDirectory(Path.Combine("<Your temp folder>", "<DirectoryName>"));
Make sure you have the proper rights given to the aspnet worker process to create the folder.
Kirtan
2009-04-21 08:20:24
This may throw easily. Use Path.Combine(root,subfolderName); instead of root+ "\\" + subfoldername
Krzysztof Koźmic
2009-04-21 08:24:45
A:
System.IO.Directory.CreateDirectory()
is what you're looking for.
snowcrash09
2009-04-21 08:20:26
+1
A:
string tempFolderAbsolutePath = @"C:\Temp";
string subFolderRelativePath = @"SubTemp1";
DirectoryInfo tempFolder = new DirectoryInfo( tempFolderAbsolutePath );
DirectoryInfo subFolder = tempFolder.CreateSubdirectory( subFolderRelativePath );
string tempFileName = String.Concat( Guid.NewGuid().ToString(), @".tmp" );
string textData = @"Temp text data";
using (StreamWriter streamWriter = File.CreateText( Path.Combine( subFolder.FullName, tempFileName ) ))
{
streamWriter.Write( textData );
streamWriter.Flush();
streamWriter.Close();
}
Leonid Shirmanov
2009-04-21 13:19:29