I'm trying to save the path of a file (with the file name included) to a database column. Imagine my project directory is called Project, there I have a folder called Attachments.
In my code I'm doing this to upload the file to the location I choose:
string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath("~/Attachments/") + filename);
This works great and if I open that folder the file is there! Now my problem is with saving the path+filename
to database column. I'm currently using Server.MapPath(FileUploadControl.FileName)
, but when I check in database column it only saves the path string until my Project, like C:\[somepath]\Project\
.
So it's missing the Attachments folder and the file name. Any help? I already read a lot of topics about FileUploadControl
here but nothing helped me.
I'm using ASP.NET C# and the column type saving that information is in varchar(MAX)