Where can I write a temp file from 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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x