Results 1 to 5 of 5

Thread: How to count and delete temp file from system folder using coding?

  1. #1
    Join Date
    Nov 2009
    Posts
    36

    How to count and delete temp file from system folder using coding?

    Hi,
    I am internet user and because of this I get lots TEMP files in my Temp folder, and every day I don’t want to delete open temp file and remove or delete this file, for that I try to make own application which directly delete all the files from the temp folder. But I don’t have any idea how to count and delete temp file from system folder using coding

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to count and delete temp file from system folder using coding?

    Use following code for counting and deleting the files from any folder
    for /f "tokens=1 delims=F" %%a in ('dir /s /a-d ^| find " File(s) "')
    do (set /a p+=%%a echo %%a)
    echo %p%
    "del /s"
    subtract (dif=newct-oldct).
    After counting all the files from the temp folder in your system drive you get the log.txt file, in that you get all the counting of all deleted files.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to count and delete temp file from system folder using coding?

    Use following VB code for deleting files from the folder
    Private Sub fdel(fname As String)
    Dim fileobj As Object
    Set fileobj = CreateObject("Scripting.fileobj")
    fileobj.delfile fname, True
    End Sub
    Private Sub Command1_Click()
    fdel (fname)
    End Sub

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: How to count and delete temp file from system folder using coding?

    This VB code is use full for an API call. This code is very easy and faster to compiling.
    Private Declare Function Delfile Lib "kernel32" Alias "DelfileA" (ByVal fname As String) As Long
    Private Sub Command1_Click()
    Dim File As String
    File = "TEMP folder path"
    Delfile File
    End Sub

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to count and delete temp file from system folder using coding?

    Use SHFileOperation to send a file to the recycle bin.
    VB Code:
    Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" ( fileopen As SHFILEOPSTRUCT ) As Long
    Private Const FO_DELETE = &H3
    Private Const FOF_ALLOWUNDO = &H40
    Private Type SHFILEOPSTRUCT
    thwnd As Long
    wFunca As Long
    pFrom As String
    pToa As String
    fFlagsa As Integer
    fAborteda As Boolean
    hNameMapsa As Long
    sProgressa As String

    End Type
    Public Sub DeleteFile(ByVal sfilnam As String)
    Dim fo As SHFILEOPSTRUCT
    With fo
    .pFrom = sfilnam & vbNullChar
    .wFunca = FO_DELETE
    .fFlags = FOF_ALLOUNDO
    End With
    Call SHFileOperation(fo)
    End Sub

Similar Threads

  1. How to delete temp file in window 7?
    By JeetVerma in forum Networking & Security
    Replies: 2
    Last Post: 17-02-2012, 03:02 PM
  2. How to Delete set3.temp files from windows folder
    By afidelino in forum Windows Software
    Replies: 4
    Last Post: 01-04-2010, 06:01 PM
  3. Delete the temp folder in Vista?
    By Parker in forum Operating Systems
    Replies: 5
    Last Post: 27-03-2009, 03:19 PM
  4. Strange file with a dog icon in the c:\windows\temp folder....
    By Henri@ksen in forum Small Business Server
    Replies: 2
    Last Post: 18-08-2008, 10:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,358,726.92742 seconds with 16 queries