VintaSoft Imaging .NET SDK and Plug-ins Discussions

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

File in use after appending tif page



File in use after appending tif page

Post by philip.y »

I'm getting a file in use when tring to delete the file I am appending. I've tried disposing the tif object but this crashes the app.


  Private Function AppendPage(ByVal sourceFile As String, ByVal newPage As String) As Boolean

        Dim tif As New Vintasoft.Imaging.Codecs.Tiff.TiffFile(sourceFile)

        Try
            tif.Pages.Add(New VintasoftImage(newPage))
            tif.SaveChanges()

        Catch ex As Exception
            Throw
        End Try
        Return True

    End Function


' Subsequent delete generates the error:
IO.File.Delete(newPage)
[/color]

Any ideas?


Re: File in use after appending tif page

Post by Alex »

Hello Philip,

You need to save a reference to the VintasoftImage object and dispose this object before removing the file.

Here is correct code:
Private Function AppendPage(ByVal sourceFile As String, ByVal newPage As String) As Boolean

    Using tif As New Vintasoft.Imaging.Codecs.Tiff.TiffFile(sourceFile)
        Try
            Using image As VintasoftImage = New VintasoftImage(newPage)
                tif.Pages.Add(image)
                tif.SaveChanges()
            End Using
        Catch ex As Exception
            Throw
         End Try
    End Using

    Return True

End Function
Best regards, Alexander


Re: File in use after appending tif page

Post by philip.y »

Alex,

Great - works a treat thanks!

Phil


Page 1 from 1: 1