Urgent please: strange problem with file uploading
-
Hi there I upload files the same way everyone does: HTML:
Code: FileUpload1.SaveAs(savePath); which works almost fine. When the code finishs, the file is saved in the desired location but it somehow remains open! (thus inaccessible for writing, deleting, etc.) until I restart aspnet_wp.exe. I am really stuck with this problem, because I even tried my own way of saving the file (instead of using SaveAs): int len = FileUpload1.PostedFile.ContentLength; byte[] buffer = new byte[len]; FileUpload1.PostedFile.InputStream.Read(buffer, 0, len); FileStream file = new FileStream(savePath, FileMode.Create); file.Write(buffer, 0, len); file.Close(); // notice that I don't forget to close the file But the problem survived - the file still remains open although I explicitly call .Close() which is pretty puzzling for me! Can anyone please help me out? Thanks thousand times, H.
-
Hi there I upload files the same way everyone does: HTML:
Code: FileUpload1.SaveAs(savePath); which works almost fine. When the code finishs, the file is saved in the desired location but it somehow remains open! (thus inaccessible for writing, deleting, etc.) until I restart aspnet_wp.exe. I am really stuck with this problem, because I even tried my own way of saving the file (instead of using SaveAs): int len = FileUpload1.PostedFile.ContentLength; byte[] buffer = new byte[len]; FileUpload1.PostedFile.InputStream.Read(buffer, 0, len); FileStream file = new FileStream(savePath, FileMode.Create); file.Write(buffer, 0, len); file.Close(); // notice that I don't forget to close the file But the problem survived - the file still remains open although I explicitly call .Close() which is pretty puzzling for me! Can anyone please help me out? Thanks thousand times, H.