-
File Renaming
HI all,
VB.NET
---------
I am displaying the images in a "Picture Box" one by one, and the user can add the selected images to the listbox.
From the ListBox i am trying to Rename the "Selected File" from the Listbox and upload it to the server using FTP.
When i am trying to Rename the file it is giving an error saying "The file filename.jpg is being used by another process" whereas the file i am not using in any application.
Please give me the solution.
Thanks in advance.
Regards
Nag K.
-
What's the code you're using to upload the images to the picture box? I've been doing quite a lot of image management lately, although not with FTP.
Just off the top of my head, if you're using a Stream of some kind to grab the image then make sure that after the image is uploaded you close the stream object and any readers you're using.
The cause for the "file is being used by another process" type error with me is typically due to a stream object still being open.
Good luck,
Daniel Gow
Here's how I usually grab images...
Code:
Public Function ReturnImage(ByVal image_path) As Image
Dim fso As IO.FileStream
Dim img As Drawing.Bitmap
Try
fso = New IO.FileStream(image_path, IO.FileMode.Open)
img = New Drawing.Bitmap(fso)
fso.Close()
Return img
Catch ex As Exception
Err(ex)
End Try
End Function
So on my form it'd be...
Code:
PictureBox1.Image = ReturnImage("filename")