Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I write a temp file from ASP.NET?

Tags:

asp.net

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?

like image 643
ProfK Avatar asked Apr 18 '10 08:04

ProfK


1 Answers

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.

like image 56
Oded Avatar answered Oct 20 '22 06:10

Oded