UploadFileControl.SaveAs(fileName)的替代方案

时间:2013-11-07 14:46:10

标签: c# asp.net .net file-upload

我可以使用另一种方法,在上传文件时获取“写入的字节数”或类似内容吗?我想要一个进步,这是所写数据的实际进展,或者使用这个类和方法是不可能的?如果没有,请研究什么途径?

感谢。

基本示例:

if(FileUpload1.HasFile)
{
  savePath += FileUplaod1.FileName;
  FileUpload1.SaveAs(savePath); ///  Here is where I want to do a stream or some way to grab
   //bytes written so I can do an async on it and show the progress, not wait until it is copleted, and then show a label status of "completed". Doing this for a form that has to be non-html5 compatibale. That is why I am not using a different method.  

}

2 个答案:

答案 0 :(得分:1)

HttpPostedFile file = context.Request.Files [“userfile”];             file.ContentLength;

答案 1 :(得分:0)

我明白了。昨晚这么晚,完全忽略了这个。

bytes[] filebytes = UplaodFile1.FileBytes ;
//Now I can send to stream.....