12

I have an 'access denied' problem on an ASP.NET web application, where the user uploads an Excel file and I try and write it to a folder. I don't have access to the host except FTP, so I can't set permissions. I thought that ASP.NET would be able to write to a folder that is under the web app root, but it isn't so.

Is there anywhere I can write the file to that doesn't require me to set permissions?

ProfK
  • 49,207
  • 121
  • 399
  • 775
  • I use shared hosting with a few different companies, and I am allowed to set permissions on folders. You should look into this further with the tech support department of your host. – TheGeekYouNeed Apr 18 '10 at 12:21
  • @Cen, it's not an issue of being allowed to set permissions or not, but rather that at this time I only have FTP access to my client's host server. – ProfK Apr 18 '10 at 14:45

1 Answers1

23

ASP.NET can write to a folder if the account under which it is running (the application pool user) has write permissions on it.

If this is indeed a temporary file, you can get a filename from the Path class using GetTempFileName():

string tempPath = Path.GetTempFileName();

You can use this in conjunction with IsolatedStorage to be sure you have permissions to write to a folder.

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Oded
  • 489,969
  • 99
  • 883
  • 1,009