c# - Could not find file 'c:\windows\system32\inetsrv\xxx.xlsx' -
i have mvc application reads , uploads excel file , processes file in app, works fine on local machine, deploy server,i following error above. have added permissions iis app pool user root folder, browse file through app on local machine, fails above error. if test on deployed server works fine. idea is, have seen lot of posts on this, tried suggestions no luck. ideas, please see code below.
try { if (file.contentlength > 0) { var filename = file.filename; var targetfolder = server.mappath("/"); string targetpath = path.combine(targetfolder, filename); file.saveas(targetpath);
you should use tilde symbol(~) point root of application
server.mappath("~/");
and it's better use subfolder (make sure there folder)
server.mappath("~/uploads/")
Comments
Post a Comment