PDA

View Full Version : مشکل پر شدن temp



packet
دوشنبه 18 آبان 1388, 15:14 عصر
سلام خدمت اساتید
هنگام اجرا کردن گزارشم temp ویندوز پر میشه به حدی که درایو ویندوزم کامل پر میشه کسی میتونه کمکم کنه که temp رو توی برنامه خالی کنم ؟؟؟؟؟؟؟؟؟

milad.biroonvand
سه شنبه 26 آبان 1388, 17:12 عصر
از این کد استفاده کن


''' <summary>
''' Method for deleting all the files in a directory
''' in a specified directory
''' </summary>
Public Function RecursiveDelete(ByVal dir As String) As Boolean
'always use a try...catch to deal
'with any exceptions that may occur
Try
'first make sure the directory exists
'if it doesn't and we try to delete the
'file an exception is thrown
If Not System.IO.Directory.Exists(dir) Then
_status = False
'throw the exception to be dealt with later
Throw New DirectoryNotFoundException(dir + " cannot be found! Please retry your request")
Else
'retrieve all the files and put them into a string array
Dim names As String() = Directory.GetFiles(dir)
'now loop through all the files and delete them
For Each file As String In names
System.IO.File.Delete(file)
Next
_status = True
'let the user know it was successful
_returnMessage = "All files deleted successfully!"
End If
Catch ex As Exception
_status = False
'handle any errors that occurred
_returnMessage = ex.Message
End Try
Return _status
End Function