如何从File处理程序文件中获取FileStream中的Length? [英] How to get Length in FileStream From .NET handler file?

查看:384
本文介绍了如何从File处理程序文件中获取FileStream中的Length?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.........



i面临一个问题,即从文件流中获取长度...当我要上传jpeg时使用处理程序文件的图像...



一些时间长度变为零...这是我面临的问题..

PLZ给我一些解决方案

hi.........

i have facing one issue which is not getting length from File Stream.. when i am going to upload jpeg image using handler file...

Some time length getting as zero... this is what a issue i am facing..
plz give me some solutions

推荐答案

您可能正在尝试重新打开文件流,试试这个。



You are probably trying to re-open the filestream, try this.

Dim fileStream As New IO.FileStream(mapPath & "\" & filename, FileMode.OpenOrCreate)
    If (fileStream.Length) > 50000 Then
    System.Web.HttpContext.Current.Response.Write("{success:false, errmsg:'File size is large imagesize}")
    fileStream.Close() 'Be sure to close the filestream.
    Exit Sub
End If





祝你好运。



Good luck.


这篇关于如何从File处理程序文件中获取FileStream中的Length?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆