PDA

View Full Version : Resolved asp net local directory?


Zpixel
08-30-2009, 12:16 PM
this is an asp net website.
using file.PostedFile.SaveAs("c:\\upload\\" + newFileName); the uploded file will be saved at C drive.
I want to store that file in the website folder, ie, the folder that Default.aspx exists. How should i write the path? is "|DataDirectory|\\upload\\" the correct path? but it doesn't work.

Old Pedant
08-30-2009, 07:49 PM
Try this:

PostedFile.SaveAs( Server.MapPath( "./upload/" & newFileName ) )

Zpixel
08-30-2009, 08:40 PM
thank you.

file.PostedFile.SaveAs(Server.MapPath("./upload/" + newFileName));

Old Pedant
08-31-2009, 10:49 PM
Sorry...didn't notice the semicolon and gave you VB.NET syntax instead of C#.