Reputation: 3606
I'm trying to get a file upload to work in an application I'm developing.
On my local machine I've been using the following to save the file to a folder on a shared resource:
string path = Path.Combine("\\appname\myfolder$", Path.GetFileName(file.FileName));
file.SaveAs(path);
and everything works fine.
(On the 'appname' server, the folder 'myfolder' is in the root (e.g.) c:\myfolder)
When I deploy my project to IIS on the same server (e.g. http:\appname) this no longer works.
As a result I tried to change the code to point to the c drive on the server it would be running from e.g.
string path = Path.Combine("c:\\myfolder", Path.GetFileName(file.FileName));
file.SaveAs(path);
and this didn't work either. Tried a few other things but now lost it completely. Can anybody help?
Upvotes: 0
Views: 1724
Reputation: 366
When running this application in IIS, assign an authorized user to the application context, that is hosting the website. By default the worker is running in system context and the operating system (machine account) would require access to the share - which is really not a recommendet solution.
See here how to configure the application pool identity.
Upvotes: 1