Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i created uploading and i want to create folder and want to name for that folder while uploading..how to do that can any one help me??

or for example..
in my aspx project i created many folders with name and while uploading i want to save in that particular folder..can any one suggest me..?

or can i try like this for example..

[browse file]
[textbox]
[uploadbutton]

here i wil describe..when i browse file and enter in textbox filed as Path(mean i want to save in that folder which i created in my project so i wil type that folder name to that text box..after that i wil click uploadbutton so when i upload i want tat file into that entered folder...can any one can we do like that?? i will show u my code and where i have to make changes for that help me for this...

C#
protected void btnUpload_Click(object sender, EventArgs e)
   {


       if (FileUpload1.HasFile == false)
       {

           UplodDetails.Text = "Please first select a file to upload...";
       }
       else
       {

           UplodDetails.Text = string.Format(@"Uploaded file: {0}<br />File size (in bytes):{1:N0}<br />Content-type: {2}",
                     FileUpload1.FileName,
                     FileUpload1.FileBytes.Length,
                     FileUpload1.PostedFile.ContentType);

           string filePath =
           Server.MapPath("~Uploader" + FileUpload1.FileName);

           FileUpload1.SaveAs(filePath);


       }
Posted
Updated 28-Feb-12 19:07pm
v3
Comments
ythisbug 29-Feb-12 1:36am    
i told my idea.or suggest me how to do with different method..thanks

1 solution

C#
if (!Directory.Exists(Server.MapPath(filePath)))
{                                      Directory.CreateDirectory(Server.MapPath(filePath));
}
 
Share this answer
 
Comments
ythisbug 28-Feb-12 23:42pm    
wat u mean by directory ?can u describe here..m getting error..
ZurdoDev 29-Feb-12 8:33am    
It is under the System.IO namespace.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900