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
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