Link to home
Start Free TrialLog in
Avatar of onyak

asked on

Need a solid quick solution for processing images given the scenerio

I need an alternative solution to the following problem:

I have an Windows application that used by over 100 users on a LAN.  Part of this application is used for searching and viewing product drawings.  Details on the files along with the file location on the network are stored in SQL Server 2000 and the files are stored on a shared network drive. When the application opens up files, it...
- Deletes the file if it already exist on the local hard drive
- Copies the file from the server to the local hard drive
- Parses the file out to multiple files it it's a TIF that contains multiple frames. Saving each frame as an individual file on the local hard drive.
- Watermarks each image/frame depending on set rules. (Watermarks are text)
- Recombines all frames (if any) into one file and saves the file to a new location on the local hard drive.
- Deletes any parsed frames used during this operation
- Opens the file with the specified default view (they have a choice of custom or Windows default)

When the application closed, all files are deleted to make sure it's gets a proper clean up.

The problem is the image locks don't always release. I dispose of the locks right away, but still I think this much file activity is causing a problem. Any ideas on new solutions to complete the same outcome?

Maybe by using streams, but is it possible to do this with streams?  If so, please add any code samples you can.
Avatar of ptakja
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of onyak


Oh yeah.  I totally forgot about that.  I'll give it a try and get back to you. Thanks!
Avatar of onyak


Hmm, no that didn't help.

Another issue....when the application loads, I call the following method but it fails.   Says I don't have access. But then through Windows Explorer, I can delete the files.

Public Shared Sub CleanTempDirectory()
            Dim strPath As String = "C:\AeroTemp\frames\"
            Dim strPathFinal As String = "C:\AeroTemp\"

            'clean it out
                Directory.Delete(strPath, True)
                Directory.Delete(strPathFinal, True)
                'recreate temp directory
            Catch ex As Exception

            End Try
        End Sub

The exception is.....
    [System.UnauthorizedAccessException]: {System.UnauthorizedAccessException}
    HelpLink: Nothing
    InnerException: Nothing
    Message: "Access to the path "0032355.tif" is denied."
    Source: "mscorlib"
    StackTrace: "   at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive)
   at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)
   at System.IO.Directory.Delete(String path, Boolean recursive)
   at AeroControlex.PDM.Globals.CleanTempDirectory() in C:\!Projects\Paperless Manufacturing\NET Version 2\AeroControlex PDM Client\Components\Globals.vb:line 112"
    TargetSite: {System.Reflection.RuntimeMethodInfo}
Avatar of onyak


Ok, with your code....and some other code....I finally found what worked.

                xFileI = New FileInfo(flCopy)
                xFileI.Attributes = FileAttributes.Normal