|
| |||||||||
| Tags: coding, count, count, delete, delete, file, system, temp |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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
| ||||
| ||||
| 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
| ||||
| ||||
| 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
| ||||
| ||||
| 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
__________________ The FIFA Manager 2009 PC Game |
|
#5
| ||||
| ||||
| 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
__________________ Grand Theft Auto 4 PC Video Game |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to count and delete temp file from system folder using coding?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to delete .exe file in Temp folder | Baako | Networking & Security | 6 | 19-06-2011 09:55 AM |
| How to Delete set3.temp files from windows folder | afidelino | Windows Software | 4 | 01-04-2010 07:01 PM |
| Delete the temp folder in Vista? | Parker | Operating Systems | 5 | 27-03-2009 04:19 PM |
| can not delete strange char file in internet temp folder | David | Window 2000 Help | 7 | 27-04-2007 11:38 PM |
| failed/successfull audit delete folder and delete file and folder | steef83 | Windows Security | 7 | 18-11-2006 01:23 AM |