the process cannot access the file because it is being used by another process

  • Thread starter Thread starter bala
  • Start date Start date
B

bala

Hi All,
Sorry for repost

I have a popup for image upload with a upload button,save button and one
close button
I am uploading images with a file control after browsing when I click on
upload button it
upload the file to some folder /xyz/temp/ folder with name 101.jpg
now i close the popup.
now when i again open and try to upload (upload the file to same folder
/xyz/temp/ folder with name 101.jpg)
it gives me exception on this line
inputFile.SaveAs(MapPath(/tmp+"//"+fileName));
saying
"the process cannot access the file (101.jpg)because it is being used by
another process"
this exception is thrown.
now if i restart the asp.net worker process this exception doesnt comes
that mean the file is cached in memory by the asp.net worker process.

Thanks in advance
bala
 
Hi

Thank for the reply

I am not geeting what to release the file

I m creating a object of HttpPostedFile

After use I am setting it to null

There is no property like dispose with it

I m sending u the code fragment

On postback

if(IsPostBack)

{HttpPostedFile uploadedFile = file.PostedFile;

try

{if(uploadedFile.ContentType=="image/pjpeg")

{uploadedFile.saveas(path+"101.jpg");

uploadedFile=null;

}}

Catch(){}

When user clicks on preview I am creating a datatable contains the

ImageUrl and Image(typeof(byte[])

Now I am displaying the image in pdf formate in another frame

I am not geeting what to release the file

thanks

bala
 
Back
Top