Help On Creating a Folder

Posted by Vijayar under ASP.NET on 2/20/2012 | Points: 10 | Views : 1316 | Status : [Member] | Replies : 1
Hi
I have a project under which i have a folder called,Images,under images folder i have a folder called Gallery_images.When i click on save button i need to create a
folder under Gallery_Images folder with the name given in text box.How to fo it by taking the path by using server.mappath

In form i have a textbox

vijaya


Responses

Posted by: Naraayanan on: 2/20/2012 [Member] Starter | Points: 25

Up
0
Down
Hi ,
Check this Code
public static string fname;


public static string Path;

public static string fldname;

public static bool mess;



public static bool createFolder(string sPath, string foldername)

{

#region Check folder Name

bool chkTool = Directory.Exists(sPath);

if (chkTool)

{

fname = @"\" + foldername + "\\";

fname = sPath + fname;

Directory.CreateDirectory(fname);

mess = true;

}

else if (!chkTool)

{

if (!Directory.Exists(sPath))

{

Directory.CreateDirectory(sPath);

}

fname = @"\" + foldername + "\\";

fname = sPath + fname;

Directory.CreateDirectory(fname);

mess = true;

}

#endregion Check folder Name

return mess;



}

Path = @"E:\Test";

fldname = "Test1";

bool chk = createFolder(Path, fldname);

if (chk)

{

MessageBox.Show("Folder Created");

}

else

{

MessageBox.Show("Folder is not Create");

}


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response