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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -