我在哪里可以写从ASP.NET临时文件? [英] Where can I write a temp file from ASP.NET?

查看:97
本文介绍了我在哪里可以写从ASP.NET临时文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个拒绝访问上的ASP.NET Web应用程序,用户上传一个Excel文件,我尝试,并将其写入到一个文件夹的问题。我没有访问除FTP主机,所以我不能设置权限。我认为ASP.NET将能够写这就是Web应用程序根目录下的文件夹,但事实并非如此。

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?

推荐答案

如果该帐户下运行它(应用程序池的用户)具有写权限就可以了ASP.NET可以写入到一个文件夹。

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

如果这确实是一个临时文件,可以类使用得从路径文件名<一href=\"http://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename.aspx\"><$c$c>GetTempFileName():

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

string tempPath = Path.GetTempFileName();

您可以结合使用这与 IsolatedStorage ,以确保您有写入权限一个文件夹。

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

这篇关于我在哪里可以写从ASP.NET临时文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆