Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Richard MacCutchan 21-Mar-14 6:54am    
No one can give you solutions unless you give the exact details of when this occurs, including details of the file and the code that you are using.
RiswanulZaman 21-Mar-14 7:17am    
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}")
Exit Sub
End If


this is my code.. here fileStream.Length is getting 0... i cant able to write file into the path..(tempfolder)
RiswanulZaman 21-Mar-14 8:00am    
thank u for suggestion its very useful for me... i have found the solution with the help of ur code... and also i have done with some extra lines of code that is...


Dim inputStream As Stream = HttpContext.Current.Request.InputStream
inputStream.CopyTo(fileStream)

After execution of these lines.. we can get the length of the file...


Thank u friend.....
S Houghtelin 21-Mar-14 8:08am    
I'm glad I was able to help. If you don't mind, if you could click my answer as the solution I would apreciate it.

Regards.

1 solution

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

VB
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900