tags:

views:

379

answers:

3

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
This may throw easily. Use Path.Combine(root,subfolderName); instead of root+ "\\" + subfoldername
Krzysztof Koźmic
A: 

System.IO.Directory.CreateDirectory() is what you're looking for.

snowcrash09
+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