Filelocks when opening tifffile

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

Moderator: Alex

Post Reply
philip.y
Posts: 12
Joined: Tue May 31, 2011 11:09 pm

Filelocks when opening tifffile

Post by philip.y »

Hi there,

I have an issue which only occurs intermittently on workstations running win7 or above, not on XP machines. Its only become a problem now because the customer has only just migrated to Windows 7 (not kidding!)

When trying to open the tiff to interrogate it, I get:
The process cannot access the file 'xxxx.tif' because it is being used by another process.
Obviously I'd expect this if the thumbnail viewer had the file open - it doesn't and I make double sure by closeanddispose on it before calling the routine.

The routine in question simply checks if any of the pages in a tiff file are colour and returns true/false. Eg:

Code: Select all

                 Using tif As New Vintasoft.Imaging.Codecs.Tiff.TiffFile(sourceFile, readOnlyAccess:=True)
                        For Each page In tif.Pages
                            If (page.BitsPerPixel) >= 24 Then
                                bCol = True
                                Exit For
                            End If
                        Next
                    End Using
I've also tried opening as a stream as follows but get the same.

Code: Select all

                 Using tif As New Vintasoft.Imaging.Codecs.Tiff.TiffFile(memstream)
                        For Each page In tif.Pages
                            If (page.BitsPerPixel) >= 24 Then
                                bCol = True
                                Exit For
                            End If
                        Next
                    End Using
In a desparate hack I even tried to copy to a temp file and use this for the test but again, makes not difference.

I've looked at opportunistic locking and also any issues on the server where the tif files are located but not found any.

Any suggestions?

Cheers

Phil
philip.y
Posts: 12
Joined: Tue May 31, 2011 11:09 pm

Re: Filelocks when opening tifffile

Post by philip.y »

To clarify, the memStream object is a filestream (rather than a memorystream - sorry for confusing naming!)

Code: Select all

 Dim memStream As FileStream = New FileStream(sourceFile, FileMode.Open, FileAccess.Read)
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Filelocks when opening tifffile

Post by Alex »

Hello Phil,

I think your code has logical mistake. Please send us (to support@vintasoft.com) working application, which demonstrates your problem - we need analyze your code.

Best regards, Alexander
philip.y
Posts: 12
Joined: Tue May 31, 2011 11:09 pm

Re: Filelocks when opening tifffile

Post by philip.y »

Hi Alex,

Its a large application with other 3rd party controls so not practical - I doubt that I would have permission anyway.

Here's the full routine instead which is simply designed to return true if at least one of the pages is colour.

Cheers

Phil

Code: Select all

Public Function ContainsColour2(ByVal sourceFile As String, Optional ByRef err As String = "", Optional fileStreamFile As FileStream = Nothing) As Boolean
            Dim bCol As Boolean = False

            Try
                '
                ' // Do we have any colour pages
                '
                If sourceFile = String.Empty Then
                    Using tif As New Vintasoft.Imaging.Codecs.Tiff.TiffFile(fileStreamFile)
                        For Each page In tif.Pages
                            If (page.BitsPerPixel) >= 24 Then
                                bCol = True
                                Exit For
                            End If
                        Next
                    End Using
                Else
                    Using tif As New Vintasoft.Imaging.Codecs.Tiff.TiffFile(sourceFile, readOnlyAccess:=True)
                        For Each page In tif.Pages
                            If (page.BitsPerPixel) >= 24 Then
                                bCol = True
                                Exit For
                            End If
                        Next
                    End Using
                End If

            Catch ex As Exception

                Call ExceptionOccured(ex, True, False)
                err = ex.Message

            End Try
            Return bCol

        End Function

    End Module
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Filelocks when opening tifffile

Post by Alex »

Hi Phil,

You are using the Vintasoft.Imaging.Codecs.Tiff.TiffFile class and this means that you are using SDK version 7.x or earlier. Please try to use the latest version (8.3) of SDK and let me know results. We cannot reproduce your problem with the latest version of SDK.

Best regards, Alexander
philip.y
Posts: 12
Joined: Tue May 31, 2011 11:09 pm

Re: Filelocks when opening tifffile

Post by philip.y »

Hi Alex,

Yes its an older product using 5.x of Imaging. Too much work to upgrade to 8.x and customer wouldn't pay for it anyway.

Thanks anyway - I'll find a workaround.

Cheers

Phil
Post Reply