如何获取FTP文件大小
RT
------解决方案--------------------获取文件列表
Code:
public string[] GetFileList()
{
string[] downloadFiles;
StringBuilder result = new StringBuilder();
FtpWebRequest reqFTP;
try
{
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(
"ftp:// " + ftpServerIP + "/ "));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserID,
ftpPassword);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
WebResponse response = reqFTP.GetResponse();
StreamReader reader = new StreamReader(response
.GetResponseStream());
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append( "\n ");
line = reader.ReadLine();
}
// to remove the trailing '\n '
result.Remove(result.ToString().LastIndexOf( '\n '), 1);
reader.Close();
response.Close();
return result.ToString().Split( '\n ');
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
downloadFiles = null;
return downloadFiles;
}
}
具体察看http://bbs.msproject.cn/default.aspx?g=posts&t=233
------解决方案--------------------int fileSize1 = Request.Files[ "mainResourceFile "].ContentLength;
这句就可以获得上传文件的大小。。。