Visual Basic .NET,FileStreams, BinaryFormatters, Files, Errors, Changes, Help!!

medubose

New member
Joined
Feb 3, 2003
Messages
2
I have this save function that uses the code block below. Each time a new level is created the current level of graphics need to be saved and this works fine unless there has been no changes to the current level. I then receive Error: Additional information: The process cannot access the file "C:\KP\Level1.dat" because it is being used by another process.

So I have two Questions

How do I compare the file with the in memory file for changes?

How do I overwrite the stored file changed or not?

Code:
Try
                Dim settingsPath As String = fileName
                Dim myBinarySerializer As New Formatters.Binary.BinaryFormatter()
            myBinarySerializer.Serialize( _
                New IO.FileStream(settingsPath, IO.FileMode.OpenOrCreate), _
                Me.drawingObjects)
            Todo if file has changed then save
            RaiseEvent StatusUpdate(Me, _
                New StatusUpdateEventArgs(StatusUpdateType.FileSaved, _
                SelectedGraphic, _
                String.Format("Graphic Level saved to file {0}", fileName), _
                Nothing, Nothing))
        Catch e As Exception

            Throw New ApplicationException(("Save Failed." & fileName & vbCrLf & vbCrLf), e)
        End Try
 
Last edited by a moderator:
Back
Top