日期:2014-05-18  浏览次数:21225 次

C#下载ftp文件报550错误:“文件不可用或无法访问”
public void DownFile(string TargetPath)
  {
  try
  {
  Connect(uri);
  reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
  FtpWebResponse ftpResponse = (FtpWebResponse)reqFTP.GetResponse();
  Stream s = ftpResponse.GetResponseStream();
  FileStream fs = new FileStream(TargetPath, FileMode.Create);
  byte[] bt = new byte[4096];
  while (s.Read(bt, 0, bt.Length) > 0)
  {
  fs.Write(bt, 0, bt.Length);
  }
  ftpResponse.Close();
  fs.Close();
  }
  catch (Exception ex)
  {
  MessageBox.Show(ex.Message, "下载错误");
  }
  }

------解决方案--------------------
应该是文件的权限问题了,你把需要操作的文件权限设置一下试试看