我想不 http://localhost/updatePro/BBS.zip 这个压缩包
写入当前项目中直接运行项目获取是正常的。。
发布到IIS后运行出现异常 System.UnauthorizedAccessException: 对路径“F:\WINDOWS\system32\BBS.zip”的访问被拒绝代码:
string strImageURL = "http://localhost/updatePro/BBS.zip"; System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strImageURL);
webRequest.Method = "GET";
System.Net.HttpWebResponse webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse(); System.IO.Stream s = webResponse.GetResponseStream(); List<byte> list = new List<byte>();
while (true)
{
int data = s.ReadByte();
if (data == -1)
break;
else
{
byte b = (byte)data;
list.Add(b);
}
}
byte[] bb = list.ToArray();
System.IO.File.WriteAllBytes("BBS.zip", bb); s.Close();
写入当前项目中直接运行项目获取是正常的。。
发布到IIS后运行出现异常 System.UnauthorizedAccessException: 对路径“F:\WINDOWS\system32\BBS.zip”的访问被拒绝代码:
string strImageURL = "http://localhost/updatePro/BBS.zip"; System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strImageURL);
webRequest.Method = "GET";
System.Net.HttpWebResponse webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse(); System.IO.Stream s = webResponse.GetResponseStream(); List<byte> list = new List<byte>();
while (true)
{
int data = s.ReadByte();
if (data == -1)
break;
else
{
byte b = (byte)data;
list.Add(b);
}
}
byte[] bb = list.ToArray();
System.IO.File.WriteAllBytes("BBS.zip", bb); s.Close();
解决方案 »
- 文本编辑器
- sqlserver2000 中sql 相同表中的数据是过滤,不同数据进行合并。
- Gridview...Checkbox...选择三个之后,其他的全部enable=false...谢谢
- 如何批量修改生成的静态页面呢?(原有模板变化如何替换到已经生成的页面)
- IMAGE绑定不乐图片。急
- 强烈要求重新选举Asp.net版主
- 菜鸟问题!!进来看看!
- 关于往DataTable动态增加一行数据的求解
- 我正在做的一个项目出现了一个倒霉透顶的错误,请高手指点
- 不要怪我浪费分,这个问题我实在没搞明白,岂是一个"菜"形容得了,老问题,上传文件到SQL数据库varbinary字段中,有事没事再下载下来看看,其实
- Response.BinaryWrite() IE8下载反应慢
- 发现好东西aspmaker10,大家觉得怎么样?
如果非要用这个下面的文件
system32 给它权限。everyone 权限。读写的。不过不是应该在updatePro这下面吗?
//方案一
//string strImageURL = "http://localhost/updatePro/BBS.zip";
//System.Net.WebClient webClient = new System.Net.WebClient();
//webClient.DownloadFile(strImageURL, "BBS.zip");
//方案二
//string strImageURL = "http://localhost/updatePro/BBS.zip"; //System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strImageURL);
//webRequest.Method = "GET";
//System.Net.HttpWebResponse webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse(); //System.IO.Stream s = webResponse.GetResponseStream(); //List<byte> list = new List<byte>();
//while (true)
//{
// int data = s.ReadByte();
// if (data == -1)
// break;
// else
// {
// byte b = (byte)data;
// list.Add(b);
// }
//}
//byte[] bb = list.ToArray();
//System.IO.File.WriteAllBytes("BBS.zip", bb);
//s.Close(); //方案三
WebClient wc = new WebClient();
byte[] imgData = wc.DownloadData("http://localhost/updatePro/BBS.zip");
wc.DownloadFile("http://localhost/updatePro/BBS.zip", "BBS.zip");
那么路径是Server.MapPath("~/");
而不是"BBS.zip"。
另外,数据文件要写在app_data文件夹下,例如目标文件为Server.MapPath("~/app_data/bbs.zip");[/ 不要向app_data以外的文件夹写文件,那会随时造成你的asp.net应用程序重启。
如果你是从网上看到这个“说明”,那么那是很悲催的说明。你想想,一台主机上有几个甚至几百个网站应用,要是每一个都能随便胡乱改写自己网站以外的文件夹下的文件,那么这些网站自身不就乱了嘛?!而且提供这个主机的人/公司还怎么提供服务?!如果你写asp.net应用并且发布到服务器上去,你的程序就不要随便去硬要访问网站以外的什么文件。那种遇到这种问题就想当然地“给文件夹设置权限”的想法是极端地“败事有余”的错误概念。