Click here to Skip to main content
Rate this: bad
good
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
Edited 28-Feb-12 19:07pm
v3
Comments
ythisbug at 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 at 28-Feb-12 23:42pm
   
wat u mean by directory ?can u describe here..m getting error..
ryanb31 at 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
0 OriginalGriff 349
1 Nirav Prabtani 268
2 Richard Deeming 210
3 CHill60 170
4 _Amy 145
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,067
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 29 Feb 2012
Copyright © CodeProject, 1999-2014
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