Click here to Skip to main content
12,510,836 members (50,035 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
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...

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 27-Feb-12 22:31pm
ythisbug2.1K
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

if (!Directory.Exists(Server.MapPath(filePath)))
{                                      Directory.CreateDirectory(Server.MapPath(filePath));
}
  Permalink  
Comments
ythisbug 28-Feb-12 23:42pm
   
wat u mean by directory ?can u describe here..m getting error..
ryanb31 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 29 Feb 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100