cant save the image on the same file that I load from
ehehehe :( why is it like this:
Dim img As Image = Image.FromFile("c:\funny.jpg")
img.Save("C:\funny.jpg")
this would give me an error. It works if I try to save it on some other file. It seems like you can't save the image on the same file that you load it from (well unless you clone the image, dispose it, and then try to save the cloned image. but thta's a lot of overhead/inefficient work)
any way to get around this?
Re: cant save the image on the same file that I load from
Quote:
Originally posted by MrPolite
ehehehe :( why is it like this:
Dim img As Image = Image.FromFile("c:\funny.jpg")
img.Save("C:\funny.jpg")
this would give me an error. It works if I try to save it on some other file. It seems like you can't save the image on the same file that you load it from (well unless you clone the image, dispose it, and then try to save the cloned image. but thta's a lot of overhead/inefficient work)
any way to get around this?
nope, sounds like I cant even clone it. it gives an error on the last line
VB Code:
Dim path As String = "c:\funny.jpg"
Dim fs As New IO.FileStream(path, IO.FileMode.Open)
Dim img As Image = Image.FromStream(fs)
Dim img2 As Image = DirectCast(img.Clone, Image)
fs.Flush()
fs.Close()
img.Dispose()
img2.Save(path)