c# - Save Paths, Virtual directories, and static locations -
c# - Save Paths, Virtual directories, and static locations -
i had file upload uploading folder in web application root, i.e. had
string savepath = @"~/documentation/" string filename = path.getfilename(fileuploadcontrol.filename); fileuploadcontrol.saveas(server.mappath(savepath) + filename);
and worked fine, uploading file webapp/documentation/filename.abc
the problem is, want alter documentation location don't have move folder when pushing development production. did following
in web.config:
<appsettings> <add key="documentationlocation" value="c:\documentation\" /> </appsettings>
in code:
string savepath = configurationsettings.appsettings["documentationlocation"]; string filename = path.getfilename(fileuploadcontrol.filename); fileuploadcontrol.saveas(server.mappath(savepath) + filename);
i figured work identically, saving file folder specified in web.config.
however, error when seek upload document now, says:
'c:\tm_documentation\' not valid virtual path.
any thought i'm doing wrong can prepare , save files outside of web app directory? thanks.
remove server.mappath()
, don't need server map path you, because giving total path already.
c# asp.net
Comments
Post a Comment