Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , , , ,

Sponsored Links



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

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 23-01-2010
Member
 
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
Reply With Quote
  #2  
Old 23-01-2010
Modifier's Avatar
Member
 
Join Date: Jan 2008
Posts: 1,502
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.
Reply With Quote
  #3  
Old 23-01-2010
MindSpace's Avatar
Member
 
Join Date: Feb 2008
Posts: 1,832
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
Reply With Quote
  #4  
Old 23-01-2010
opaper's Avatar
Member
 
Join Date: May 2008
Posts: 2,362
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
Reply With Quote
  #5  
Old 23-01-2010
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,299
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 11:19 AM.