Audax321 Posted August 14, 2003 Posted August 14, 2003 Hello, I'm writing a program that gets the path to an image and sets it to an image variable: Dim file as String Dim CurrentImage as Image file = "C:\wallpaper.bmp" CurrentImage = Image.FromFile(file) Then, I resize the picture and save it as another filename... CurrentImage = CurrentImage.GetThumbnailImage(NewSize.Width, NewSize.Height, Nothing, Nothing) CurrentImage.Save(NewPath & "\" & "newname.bmp") And, finally the problem occurs: Kill(file) The program will not let me delete the original file because it is being used by another process (which is my program). I found out it was my program because if I delete the image before any of the above code runs, the file is deleted fine. How can I do this in a way that will let me delete the file???? :confused: Quote
Diablicolic Posted August 14, 2003 Posted August 14, 2003 perhaps after saving the file is still being of use. I would create a timer, wait a few seconds, and then go with the killing of the file. ----------- Actually the image is still in the variable CurrentImage, so try going like this if it is available to the CurrentImage variable: CurrentImage.Dispose Or something like: CurrentImage = Nothing Before you kill the file. Quote "Reality is fake, Dreams are for real"
Audax321 Posted August 14, 2003 Author Posted August 14, 2003 Hello, Thanks.. CurrentImage.dispose allowed me to delete the files... :) Quote
Audax321 Posted August 16, 2003 Author Posted August 16, 2003 I ran into another problem. When I tested my application in the previous post, I accidentally left out the resize feature. If I put the image resizing back in, which is done by using GetThumbNail on the Image variable, it again does not allow me to delete the original file. This is understandable because I'm sure VB.NET uses the file while it is resizing it, but it won't give up control of the file even after both Image = Nothing and Image.dispose() are run... Any suggestions??? Quote
Oriolesboy Posted August 17, 2003 Posted August 17, 2003 http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=132493&Page=1#132493 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.