返回首页

获得FTP 505错误:我得到一个错误,当我运行下面的代码。发生这种情况时,只有我一个双赢XP的机器上运行的exe。对于WIN-7,它是工作的罚款。

private bool GetFileSize(FileInfo targetFI, long FileUploadedSize, string g_Subdivision,TMWaitDialog tmwaitdialog)

          {

              FtpWebRequest reqFTP;

              long fileSize = 0;

              try

              {

                  string Uri = string.Empty;

                  Uri = @"ftp://" + ftpServerIP + "/" + g_Subdivision + "/" + targetFI.Name.ToUpper().Trim();

                  reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(Uri.Trim()));

                  reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;

                  reqFTP.UseBinary = true;

                  reqFTP.KeepAlive = false;

                  reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);

                  FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();

                  Stream ftpStream = response.GetResponseStream();

                  fileSize = response.ContentLength;

                  

                  ftpStream.Close();

                  response.Close();

                return (fileSize == FileUploadedSize);

              }

              catch (Exception ex)

              {

                  MessageBox.Show(ex.Message);

                  return false;

              }

             

          }


下文提到的错误,我当我运行的EXE。
远程服务器返回错误:(550)文件不可用(例如,未找到文件,没有访问)
注:g_Subdivision表示FTP文件夹的名称
文件路径是正确的,该文件在FTP存在。
有人可以帮我整理的问题。

回答