How can i create folder and delete folder in asp.net of c# project?

imtommy

Newcomer
Joined
Mar 2, 2004
Messages
8
How can i create folder and delete folder in asp.net of c# project?

private void CreateDir()
{
string path1 = "C:\\abc\\";
string path2 = "C:\\Inetpub\\wwwroot\\XML\\144\\";


try
{

if (Directory.Exists(path))
{
return;
}

DirectoryInfo di = Directory.CreateDirectory(path);
DirectoryInfo di2 = Directory.CreateDirectory(path2);

}

catch (Exception exp)
{
}



}

I can't create folder when the path is path2, but i can create in path1,

also i can delete the folder when the path is 1 and 2..

I can't use the followng command to remove folder in 1 and 2.

{
DirectoryInfo di = Directory.CreateDirectory(path);
di.Delete(path,true);
}

why?


Thx~~
 
----------------------------
~Revised Question~
----------------------------

private void CreateDir()
{
string path1 = "C:\\abc\\";
string path2 = "C:\\Inetpub\\wwwroot\\XML\\144\\";


try
{

if (Directory.Exists(path))
{
return;
}

DirectoryInfo di = Directory.CreateDirectory(path);
DirectoryInfo di2 = Directory.CreateDirectory(path2);

}

catch (Exception exp)
{
}



}

I can't create folder when the path is path2, but i can create in path1.
I also can't delete the folder when the path is 1 and 2..

I can't use the followng command to remove folder in 1 and 2.

{
DirectoryInfo di = Directory.CreateDirectory(path);
di.Delete(path,true);
}

why?


Thx~~
 
Back
Top