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.
Thanks
Chris
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.
Thanks
Chris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Try
Directory.Delete(strPath, True)
Directory.Delete(strPathFi nal, True)
'recreate temp directory
Directory.CreateDirectory( strPath)
Catch ex As Exception
End Try
End Sub
The exception is.....
{System.UnauthorizedAccess Exception}
[System.UnauthorizedAccess Exception] : {System.UnauthorizedAccess Exception}
HelpLink: Nothing
InnerException: Nothing
Message: "Access to the path "0032355.tif" is denied."
Source: "mscorlib"
StackTrace: " at System.IO.Directory.Delete Helper(Str ing 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. CleanTempD irectory() in C:\!Projects\Paperless Manufacturing\NET Version 2\AeroControlex PDM Client\Components\Globals. vb:line 112"
TargetSite: {System.Reflection.Runtime MethodInfo }
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
Try
Directory.Delete(strPath, True)
Directory.Delete(strPathFi
'recreate temp directory
Directory.CreateDirectory(
Catch ex As Exception
End Try
End Sub
The exception is.....
{System.UnauthorizedAccess
[System.UnauthorizedAccess
HelpLink: Nothing
InnerException: Nothing
Message: "Access to the path "0032355.tif" is denied."
Source: "mscorlib"
StackTrace: " at System.IO.Directory.Delete
at System.IO.Directory.Delete
at System.IO.Directory.Delete
at AeroControlex.PDM.Globals.
TargetSite: {System.Reflection.Runtime
ASKER
Ok, with your code....and some other code....I finally found what worked.
objImage.Dispose()
GC.Collect()
Application.DoEvents()
xFileI = New FileInfo(flCopy)
xFileI.Attributes = FileAttributes.Normal
File.Delete(flCopy)
objImage.Dispose()
GC.Collect()
Application.DoEvents()
xFileI = New FileInfo(flCopy)
xFileI.Attributes = FileAttributes.Normal
File.Delete(flCopy)
ASKER