【发布时间】:2014-06-01 14:03:26
【问题描述】:
我正在尝试下载一个文件(各种文件,exe dll txt 等)。当我尝试运行它时,会出现错误:
using (FileStream ws = new FileStream(destination, FileMode.Create))
这是错误信息:
Access to the path 'C:\Riot Games\League of Legends\RADS\solutions
\lol_game_client_sln\releases\0.0.1.41\deploy'(which is my destination, where I want
to save it) is denied.
这是我的代码
void download(string url, string destination)
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential("user", "password");
request.UseBinary = true;
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
{
using (Stream rs = response.GetResponseStream())
{
using (FileStream ws = new FileStream(destination, FileMode.Create))
{
byte[] buffer = new byte[2048];
int bytesRead = rs.Read(buffer, 0, buffer.Length);
while (bytesRead > 0)
{
ws.Write(buffer, 0, bytesRead);
bytesRead = rs.Read(buffer, 0, buffer.Length);
}
}
}
}
【问题讨论】:
-
我们应该怎么做?您的应用程序对您指定的路径没有写入权限。确保确实如此。这是你的系统。
-
您几乎没有提供任何信息。你问:“这是一个非常笼统的错误信息。我没有采取任何措施来解决问题。我没有研究错误信息。我没有给你其他相关信息。请解决我的问题。”
-
我们该怎么做