Results 1 to 17 of 17

Thread: [RESOLVED] Best practice for deleting temp files (not internet cache)

  1. #1

    Thread Starter
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Resolved [RESOLVED] Best practice for deleting temp files (not internet cache)

    I'd like to delete Windows temporary files in code, and was hoping there was a Windows API call for doing this as opposed to just using Kill or whatever. Unless that's the best way?

    I've been using my own homegrown disk cleanup utility for years now, which deletes unwanted cookies, internet history, url typeahead, and temporary internet files. Plus it empties the recycle bin.

    But I was just poking around my user profile and noticed the following folder:

    C:\Documents and Settings\Ellis\Local Settings\Temp

    This folder currently contains 10,786 files in 49 folders, using up 564 megs. This is surely slowing down my virus scanning if nothing else.

    So I'd like to add the cleaning of that to my disk cleanup routine, but unfortunately it doesn't appear to be enumerated by SHGetFolderPath.

    What is the best way to clear that path?

    EDIT: Also, if there's a system-wide temp directory, as opposed to the user-specific temp files like in the above example, I'd like to be able to clear that too.
    Last edited by Ellis Dee; Jul 1st, 2010 at 05:18 PM.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Best practice for deleting temp files (not internet cache)

    See if this helps...

    http://www.hushpage.com/Visual_Basic/viper/viper.html

    Else you will have to use SHFileOperation API... Give me a moment... I will give you an example

    Edit:

    See post 4
    http://www.vbforums.com/showthread.p...HFileOperation
    Last edited by Siddharth Rout; Jul 1st, 2010 at 05:26 PM.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Best practice for deleting temp files (not internet cache)

    Quote Originally Posted by koolsid View Post
    Else you will have to use SHFileOperation API... Give me a moment... I will give you an example
    I always do; I just referenced "Kill" because it paints the picture more effectively.

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Best practice for deleting temp files (not internet cache)



    I took kill in the vb6 way... The only problem with using kill is since Local Settings\Temp is a hidden folder, it might give you problem deleting it...

    BTW, I had already posted a link... You were posting when I was editing
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Best practice for deleting temp files (not internet cache)

    Great link. As the case with so many VB6 projects' source code online, the numbskull didn't include shared modules in his zip. Not a huge deal, though, as I think I can identify and pull out what I need from it. I'll post the code I end up with for posterity.

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Best practice for deleting temp files (not internet cache)

    Quote Originally Posted by Ellis Dee View Post
    Great link. As the case with so many VB6 projects' source code online, the numbskull didn't include shared modules in his zip.
    I have booted in Vista so I don't have access to vb6 and hence I can't check it... lolzzz

    Not a huge deal, though, as I think I can identify and pull out what I need from it. I'll post the code I end up with for posterity.
    I am sure, you will
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7

    Thread Starter
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Best practice for deleting temp files (not internet cache)

    Not filled to brimming with confidence so far. To delete system temp files, the linked code does the following:
    Code:
    KillFiles Environ("windir") & "\Temp"
    
    Sub KillFiles(Path As String)
        Dim strFile As String
    
        strFile = Dir(Path & "\*.*"
        While strFile <> ""
            Kill strFile
            strFile = Dir
        Wend
    End Sub
    It actually uses While...Wend, Kill, and Environ(). Plus, none of the modules have Option Explicit, and a whole lot of other suboptimal programming practices. He even hardcoded "Temp" in there for the Windows temp folder. Ugh.

    Most irritating is that those are the only non-internet temp files it erases. It doesn't delete anything under User\Local Settings\Temp.

    I was really hoping that there was an official way to do this sanctioned by Microsoft, as opposed to just going directly to the folders and killing all the files I see.

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Best practice for deleting temp files (not internet cache)

    I guess, it is best to stay with SHFileOperation API
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9

    Thread Starter
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Best practice for deleting temp files (not internet cache)

    Let's take a step back and see if I can at least identify the folders without hardcoding them. I enumerated all folders returned by SHGetFolderPath:
    Code:
    xp.Folder.EnumerateFoldersToDebugWindow
    2: C:\Documents and Settings\Ellis\Start Menu\Programs
    5: C:\Documents and Settings\Ellis\My Documents
    6: C:\Documents and Settings\Ellis\Favorites
    7: C:\Documents and Settings\Ellis\Start Menu\Programs\Startup
    8: C:\Documents and Settings\Ellis\Recent
    9: C:\Documents and Settings\Ellis\SendTo
    11: C:\Documents and Settings\Ellis\Start Menu
    13: C:\Documents and Settings\Ellis\My Documents\My Music
    14: C:\Documents and Settings\Ellis\My Documents\My Videos
    16: C:\Documents and Settings\Ellis\Desktop
    19: C:\Documents and Settings\Ellis\NetHood
    20: C:\WINDOWS\Fonts
    21: C:\Documents and Settings\Ellis\Templates
    22: C:\Documents and Settings\All Users\Start Menu
    23: C:\Documents and Settings\All Users\Start Menu\Programs
    24: C:\Documents and Settings\All Users\Start Menu\Programs\Startup
    25: C:\Documents and Settings\All Users\Desktop
    26: C:\Documents and Settings\Ellis\Application Data
    27: C:\Documents and Settings\Ellis\PrintHood
    28: C:\Documents and Settings\Ellis\Local Settings\Application Data
    31: C:\Documents and Settings\All Users\Favorites
    32: C:\Documents and Settings\Ellis\Local Settings\Temporary Internet Files
    33: C:\Documents and Settings\Ellis\Cookies
    34: C:\Documents and Settings\Ellis\Local Settings\History
    35: C:\Documents and Settings\All Users\Application Data
    36: C:\WINDOWS
    37: C:\WINDOWS\system32
    38: C:\Program Files
    39: C:\Documents and Settings\Ellis\My Documents\My Pictures
    40: C:\Documents and Settings\Ellis
    41: C:\WINDOWS\system32
    43: C:\Program Files\Common Files
    45: C:\Documents and Settings\All Users\Templates
    46: C:\Documents and Settings\All Users\Documents
    47: C:\Documents and Settings\All Users\Start Menu\Programs\All Programs\Administrative Tools
    48: C:\Documents and Settings\Ellis\Start Menu\Programs\All Programs\Administrative Tools
    53: C:\Documents and Settings\All Users\Documents\My Music
    54: C:\Documents and Settings\All Users\Documents\My Pictures
    55: C:\Documents and Settings\All Users\Documents\My Videos
    56: C:\WINDOWS\resources
    59: C:\Documents and Settings\Ellis\Local Settings\Application Data\Microsoft\CD Burning
    No value returns C:\Windows\Temp, which is a downer. And no value returns C:\Documents and Settings\Ellis\Local Settings\Temp. Even worse, no value even returns C:\Documents and Settings\Ellis\Local Settings, meaning I'd have to do something like get the Local History folder, back up one level, and then put a hardcoded "\Temp" on the end of it.

    All of that is like a throwback to the 90s. I haven't used hardcoded system paths in so many years I can't even remember.

    Is there a more robust API than SHGetFolderPath I can use to identify more system paths?

    EDIT: Though I only went up to 255. Does SHGetFolderPath() take values larger than 255?

  10. #10
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Best practice for deleting temp files (not internet cache)

    Eli try this for me... since I cannot test it...

    Code:
    Private Declare Function GetTempPath Lib "kernel32" Alias _
    "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
    
    Const MAX_PATH = 255
    
    '~~> Retuns something like C:\DOCUME~1\user\LOCALS~1\Temp\
    Public Function GetWinDowsTempDir() As String
        Dim sRet As String, lngLen As Long
        
        '~~> Create buffer
        sRet = String(MAX_PATH, 0)
    
        lngLen = GetTempPath(MAX_PATH, sRet)
        If lngLen = 0 Then Err.Raise Err.LastDllError
        GetWinDowsTempDir= Left$(sRet, lngLen)
    End Function
    
    '~~> Use the API GetFullPathName to use GetWinDowsTempDir to get the full path
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  11. #11

    Thread Starter
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Best practice for deleting temp files (not internet cache)

    You continue to be all kinds of awesome; that returns the short path of the user temp file, the one in \User\LocalSettings\Temp. Which totally rocks.

    GetFullPathName doesn't return the long name, btw; it returns the full path and filename of a specified file, particularly useful if you're using relative paths. If you send it a short name, you get a short name back. Luckily my XP Library contains a LongFileName routine:
    vb Code:
    1. Private Const MAX_PATH = 260
    2.  
    3. Private Type FILETIME
    4.     dwLowDateTime As Long
    5.     dwHighDateTime As Long
    6. End Type
    7.  
    8. Private Type WIN32_FIND_DATA
    9.     dwFileAttributes As Long
    10.     ftCreationTime As FILETIME
    11.     ftLastAccessTime As FILETIME
    12.     ftLastWriteTime As FILETIME
    13.     nFileSizeHigh As Long
    14.     nFileSizeLow As Long
    15.     dwReserved0 As Long
    16.     dwReserved1 As Long
    17.     cFileName As String * MAX_PATH
    18.     cAlternate As String * 14
    19. End Type
    20.  
    21. Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
    22. Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
    23.  
    24. Public Function GetLongName(ByVal Folder As String) As String
    25.     Dim strToken As String
    26.     Dim lngHandle As Long
    27.     Dim strReturn As String
    28.     Dim lngTemp As Long
    29.     Dim typ As WIN32_FIND_DATA
    30.  
    31.     If Right$(Folder, 1) = "\" Then Folder = Left$(Folder, Len(Folder) - 1)
    32.     Do While lngHandle <> -1
    33.         lngHandle = FindFirstFile(Folder, typ)
    34.         strToken = Left$(typ.cFileName, InStr(typ.cFileName, vbNullChar) - 1)
    35.         If Len(Folder) > 2 Then
    36.             strReturn = strToken & "\" & strReturn
    37.             lngTemp = InStrRev(Folder, "\")
    38.             If lngTemp > 0 Then Folder = Left$(Folder, lngTemp - 1)
    39.         Else
    40.             strReturn = Folder & "\" & strReturn
    41.             Exit Do
    42.         End If
    43.         lngTemp = FindClose(lngHandle)
    44.     Loop
    45.     lngTemp = FindClose(lngHandle)
    46.     'Strip away unwanted characters.
    47.     GetLongName = Left$(strReturn, Len(strReturn) - 1)
    48. End Function

  12. #12

    Thread Starter
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Best practice for deleting temp files (not internet cache)

    I ran "Disk Cleanup" from Accessories to see if there was anything else I was missing, and I see they say outright that anything in a temp folder that's older than a week is safe to delete. Armed with that, I'm going to just iterate the temp folders and delete all the files with a DateDiff() to Now() of more than 7 days using the regular file/folder deletion code in my XP library. (SHFileOperation)

    The only remaining task before I mark this thread resolved is to identify the system temp folder (C:\Windows\Temp) without having to hardcode "Temp" on the end of the Windows folder. Any ideas? Anyone? Bueller...

  13. #13
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Best practice for deleting temp files (not internet cache)

    Ellis

    No ideas, unfortunately.
    I'm just jumping on board as a lurker.

    Great thread so far...
    Lord knows, I sorely need to do something very similar.

    Spoo

  14. #14
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Best practice for deleting temp files (not internet cache)

    You continue to be all kinds of awesome; that returns the short path of the user temp file, the one in \User\LocalSettings\Temp. Which totally rocks.
    Lolzzzz....
    I usually don't give up but when I posted "post 10", I was already half asleep. It was approx 6 AM in the morning. I was awake all night doing a freelance job...

    You can also use this in lieu of post 10!!!! SSS (Short Sweet and Simple)

    Code:
    MsgBox IIf(Environ$("tmp") <> "", Environ$("tmp"), Environ$("temp"))
    The only remaining task before I mark this thread resolved is to identify the system temp folder (C:\Windows\Temp) without having to hardcode "Temp" on the end of the Windows folder. Any ideas? Anyone? Bueller...
    Would this help?

    Code:
    Private Declare Function GetWindowsDirectory Lib "kernel32" Alias _
    "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
    ByVal nSize As Long) As Long
    
    Private Sub Command2_Click()
        Dim buffer As String * 512, length As Integer
        Dim TmpPath As String
        
        length = GetWindowsDirectory(buffer, Len(buffer))
        
        TmpPath = Left$(buffer, length) & "\Temp"
        
        If Not Dir(TmpPath, vbDirectory) = vbNullString Then
            MsgBox "Directory Temp INSIDE Windows exists. The path is " & TmpPath
        Else
            MsgBox "There is no Temp Directory INSIDE Windows Directory"
        End If
    End Sub
    Last edited by Siddharth Rout; Jul 2nd, 2010 at 01:57 AM. Reason: Typo
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  15. #15

    Thread Starter
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Best practice for deleting temp files (not internet cache)

    I'm not a fan of the Environ() function for a number of reasons, even though I am aware that the GetTempPath() is actually just a wrapper for the environment variable.

    As for hardcoding the Temp directory under Windows, yeah, that's pretty much how I'm going to implement it barring a nice API way to return that folder.

    NOTE: Check out what I found in my reading up on GetTempPath:
    The GetTempPath function checks for the existence of environment variables in the following order and uses the first path found:

    •The path specified by the TMP environment variable.
    •The path specified by the TEMP environment variable.
    •The path specified by the USERPROFILE environment variable.
    •The Windows directory.

    Note that it doesn't check whether or not the path actually exists or can be written to, so you may end up trying to write your log files to a path that doesn't exist, or one that you cannot access.
    heh, so it's not like I can just go willy-nilly delete the contents of the temp path anyway. Oops, sorry for deleting your entire user profile; you didn't want that, did you? Or even worse, say goodbye to your Windows folder. Doh!

    What kind of check should I do to ensure the safe operation of this procedure? Best solution I have is to only clear the temp folder (and all subfolders under it) if:

    LCase(Right(TempPath, 5)) = "\temp"

    So I'm hardcoding it in there anyway, no matter what. This makes me not care so much that I will be hardcoding \Temp under Windows, and for that matter I might as well check for a C:\Temp as well.

    Given this, I'm calling this thread resolved. Thanks much for your help, sid. I'd rep you if it let me.

  16. #16
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Best practice for deleting temp files (not internet cache)

    Thanks much for your help, sid. I'd rep you if it let me.
    That's OK The thought counts

    What more important is that your query is solved

    tc

    Sid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  17. #17
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: [RESOLVED] Best practice for deleting temp files (not internet cache)

    I've also seen (and found correct according to convention) that files following the pattern ~*.tmp older than a week are safe to delete. So many disk cleaning softwares go one step ahead and implement this.

    vb Code:
    1. If file Like "~*.tmp" Then
    2.     ' check if it is older than a week and delete it here
    3. End If
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

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