日期:2014-05-19  浏览次数:20473 次

请问各位高手一个问题,怎么得到上传文件的字节数啊???(解决给分!!)
我在ASP.NET页面上做了一个上传文件的功能,现在我还要得到上传文件的字节数,请问怎么做啊???

------解决方案--------------------
vb.net ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
If Not File1.PostedFile.FileName = " " Then
Label4.Visible = False
Dim hfile As HttpPostedFile = File1.PostedFile
Dim pathstr As String = "/UploadFiles/ " + hfile.FileName.Substring(hfile.FileName.LastIndexOf( "\ ") + 1)
hfile.SaveAs(Server.MapPath(pathstr))
'文件名
TextBox1.Text = hfile.FileName.Substring(hfile.FileName.LastIndexOf( "\ ") + 1)
' '文件大小
TextBox2.Text = CInt(hfile.ContentLength / 1024) & "K "

Else
Label4.Visible = True

End If
------解决方案--------------------
this.FileUpload1.PostedFile.ContentLength;
------解决方案--------------------
FileUpload控件