IOException

Salat

Well-known member
Joined
Mar 5, 2002
Messages
81
Location
Poland, Silesia
Im useing such a code
Code:
Dim BackGround as Image
Dim ffi As Integer = FreeFile()
Dim ImaPath As String = Application.StartupPath & "\EFImaSaveTmp.jpg"
FileOpen(ffi, ImaPath, OpenMode.Binary, OpenAccess.Write, OpenShare.Shared)
FilePut(ffi, stream)
FileClose(ffi)
BackGround = Image.FromFile(ImaPath)
where stream is a whole image file structure (binaries)

When I call this code once, everything is ok, but when I call it second time then this exception occurs at "FileOpen" line

An unhandled exception of type System.IO.IOException occurred in microsoft.visualbasic.dll

Additional information: The process cannot access the file "d:\Moje dokumenty\PIOTREK\Visual Studio Projects\EasyForms\bin\EFImaSaveTmp1.jpg" because it is being used by another process.

What is wrong? this file is closed...
 
Yes, you should use BinaryWriter. The FileOpen, etc. commands are
only for backward compatability and should be avoided. Theres
lots of info the in MSDN about it.
 
Back
Top