如何获取FTP文件大小

jack20my 2007-08-20 10:36:41
RT
...全文
1300 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianxiaoku 2007-08-24
  • 打赏
  • 举报
回复
真不错,学习中。。。。。。。。。。。。。。
liuyun1987 2007-08-24
  • 打赏
  • 举报
回复
int fileSize1 = Request.Files["mainResourceFile"].ContentLength;
这句就可以获得上传文件的大小。。。
jjj801206 2007-08-24
  • 打赏
  • 举报
回复
楼上的不错
ccp5780199 2007-08-20
  • 打赏
  • 举报
回复
获取文件列表


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

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧