Results 1 to 2 of 2

Thread: Vb - Crystal Report :A lot of Temporary files are left

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Bangladesh
    Posts
    48

    Vb - Crystal Report :A lot of Temporary files are left

    My application consists crystal report. When I run the application it creates a lot of temp file in root directory. They are left.
    I am using Cr 8.5. VB 6.0 in Win Xp
    Please Help urgently

  2. #2
    Addicted Member
    Join Date
    Apr 1999
    Posts
    178
    I reported the problem to Crystal Decisions. It's a known problem. Will look into it, but can not commit to fixing it. You should also report it.

    I came up with the following work around. Not all of the code is mine, alot of it came from VBForum.

    On the program main form unload event, I check to see if the os is xp. If it is, I delete all tmp files in the system root.

    Code:
     'Used to determine what version of windows is being used.
     Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA"
    (lpVersionInformation As OSVERSIONINFO) As Long
    
     Private Type OSVERSIONINFO
         dwOSVersionInfoSize As Long
         dwMajorVersion      As Long
         dwMinorVersion      As Long
         dwBuildNumber       As Long
         dwPlatformId        As Long
         szCSDVersion        As String * 128
     End Type
    
     'Platform IDs
     Private Const WIN_ID_31 = 0
     Private Const WIN_ID_95_98_ME = 1
     Private Const WIN_ID_NT_2K_XP = 2
    
    
    
    
     Public Function getOSVersion() As String
    
       Dim lVer As OSVERSIONINFO
    
       lVer.dwOSVersionInfoSize = Len(lVer)
    
       Call GetVersionEx(lVer)
    
       With lVer
          Select Case .dwPlatformId
             Case WIN_ID_31
                 getOSVersion = "Windows 3.x"
    
             Case WIN_ID_95_98_ME
                 Select Case .dwMinorVersion
                    Case 0:  getOSVersion = "Windows 95"
                    Case 10: getOSVersion = "Windows 98"
                    Case 90: getOSVersion = "Windows Me"
                 End Select
    
             Case WIN_ID_NT_2K_XP
                 Select Case True
                    Case (.dwMajorVersion < 5)
                       getOSVersion = "Windows NT"
                    Case (.dwMajorVersion = 5)
                       Select Case .dwMinorVersion
                          Case 0: getOSVersion = "Windows 2000"
                          Case 1: getOSVersion = "Windows XP"
                       End Select
                 End Select
          End Select
       End With
    
     End Function
    
    
    
     Private Sub MDIForm_Unload(Cancel As Integer)
    
       If LCase(getOSVersion) = "windows xp" Then
         Call deleteCrystalTMPFiles
       End If
    
     End Sub
    
    
     Public Sub deleteCrystalTMPFiles()
    
       Dim strRoot As String
       Dim strTmpFiles As String
    
       strRoot = Left$(App.Path, InStr(1, App.Path, "\"))
       If Len(Dir$(strRoot, vbDirectory)) Then
         strTmpFiles = Dir$(strRoot & "*.tmp")
         Do While strTmpFiles < ""
           If FileLen(strRoot & strTmpFiles) = 0 Then
             Kill strRoot & strTmpFiles
           End If
           strTmpFiles = Dir
         Loop
       End If
    
     End Sub
    Hope this helps you.

    Ken

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width