ASP.NET File Upload - Could not find a part of the path

I am performing an image upload from a local machine to an Image Stream.

It works locally all the time but now since my site was deployed to the server it works intermediately to the deployed it. I wanted to find out if anyone else has experienced this issue and resolution.

Steps
1. Use the .NET 2.0 FileUpload server control to upload a file.
2. In the C# code behind convert to byte
3. Insert into SQL Server

Code
//Convert to stream
Stream ImgStream = FileUpload1.PostedFile.InputStream;
int ImgLen = FileUpload1.PostedFile.ContentLength;
string ImgContentType = FileUpload1.PostedFile.ContentType;

//Convert to byte
byte[] ImgBinaryData = new byte[ImgLen];
int n = ImgStream.Read(ImgBinaryData, 0, ImgLen);

//Insert the image
UpdateImage(ImgBinaryData, ImgContentType, TxtAltText.Text.Trim(), FileUploadName);

Error

This error is thrown from time to time. It can be the same or a different image used for uploading

Message: Could not find a part of the path 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\0fce6ce6\807dd878\uploads\9ghvrc8j.tmp'.

Method Caused Error: Void WinIOError(Int32, System.String)

Stack Trace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)%0d%0a at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)%0d%0a at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)%0d%0a at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()%0d%0a at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension, Boolean keepFile)%0d%0a at System.Web.HttpRawUploadedContent.TempFile..ctor()%0d%0a at System.Web.HttpRawUploadedContent.AddBytes(Byte[] data, Int32 offset, Int32 length)%0d%0a at System.Web.HttpRequest.GetEntireRawContent()%0d%0a at System.Web.HttpRequest.GetMultipartContent()%0d%0a at System.Web.HttpRequest.FillInFormCollection()%0d%0a at System.Web.HttpRequest.get_Form()%0d%0a at System.Web.HttpRequest.get_HasForm()%0d%0a at System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)%0d%0a at System.Web.UI.Page.DeterminePostBackMode()%0d%0a at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Thank you,
Patrick
SURFThru.com
 
Performing some addtional tests I found that if I upload a file that is larger than 60k the upload throws the error as discussed on the the previous post.

A 65k file is small it seems odd to have this issue on posting such a small file
 
Did you ever get this resolved?

I had the same issue here with a ASP.NET site I developed for a client awhile back involving image file upload. It worked like you said, but only files less than 65k. Tech support while responsive and helpful couldn't solve it for me, or it would work for awhile and then it revert back to the same problem.

We decided to disable the file upload feature so I haven't tested recently if that 65k limit is still there.

Just curious if the file limit still holds true, in case I need to do file uploading again on shared hosting here. Partly the reason why I suggest VPS to my clients when I can.
 
Did you ever get this resolved?

I had the same issue here with a ASP.NET site I developed for a client awhile back involving image file upload. It worked like you said, but only files less than 65k. Tech support while responsive and helpful couldn't solve it for me, or it would work for awhile and then it revert back to the same problem.

We decided to disable the file upload feature so I haven't tested recently if that 65k limit is still there.

Just curious if the file limit still holds true, in case I need to do file uploading again on shared hosting here. Partly the reason why I suggest VPS to my clients when I can.
I know of people dong much more than 65k uploads in asp.net 1.1 and 2.0+

I hadn't heard of any such problem of late.
 
Did you ever get this resolved?

Andre,

As you know there is a Windows Temporary Internet folder under Windows/.NET Framework for each IIS application that runs. Sometimes the junk in there causes issues.

Jodo deleted that folder for me, for my app, then the image upload worked. Then the issue happened again, they deleted the folder. Then again...

I could not wait any longer I had a go live date to meet. So I moved the site in question that required the image upload.
 
Back
Top