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

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
 
B

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top