create sub folder in asp.net

Posted by Gopal_nivas under ASP.NET on 8/2/2010 | Views : 3548 | Status : [Member] | Replies : 2
hi..

i want to create sub folder in asp.net application.

i have main folder named"images"

so here i give the name "a" then a new sub folder will be created in images folder.
then i want to upload the image in folder"a"

again i give "a" means it wont create the same folder.. and the new image will be added into tat "a" sub folder

how to do this..

regards
gopal.s




Responses

Posted by: Poster on: 8/2/2010 [Member] Starter

Up
0
Down
Check if directory exists.

Something like

if (Directory.Exists("a"))
{
// Do not create
}
else
{
Do not create directory
}


Read articles http://www.dotnetfunda.com/articles/article548-common-operation-with-files-and-folders-in-aspnet-.aspx that will help you to understand how to work with files and folders.

Thanks

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

Posted by: Neeks on: 8/2/2010 [Member] Bronze

Up
0
Down
You can get the path for the Image folder from
"Request.PhysicalApplicationPath"

and you can combine the path with Path.Combine method.

So you can execute the condition as


if (!Directory.Exists(Path.Combine(Path.Combine(Request.PhysicalApplicationPath, "Image"), "A")))
{
// You can write code here for creating the Directory
}



Thanks,

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

Login to post response