R
Riky
hi
i have a windows application. I am select the folder or file name
from the folderbrowserdialog box and to delete the folder or file i am
calling the following code.
Public Function DeleteFile(ByVal path As String) As Boolean
'Delete a specified file
Try
If File.Exists(path) = True Then
File.Delete(path)
Return True
End If
Catch ex As Exception
Throw ex
End Try
End Function
Public Function DeleteFolder(ByVal path As String) As Boolean
'Delete a specified folder
Dim objFileInfo As FileInfo
Dim objFolder As DirectoryInfo
Dim objSubFolder As DirectoryInfo
Dim dirInfo As DirectoryInfo = New DirectoryInfo(path)
Try
If Directory.Exists(path) = True Then
objFolder = New DirectoryInfo(path)
For Each objFileInfo In objFolder.GetFiles()
objFileInfo.Delete()
Next
If dirInfo.GetDirectories.Length = 0 Then
Directory.Delete(dirInfo.FullName)
Return True
Else
For Each objSubFolder In
objFolder.GetDirectories()
DeleteFolder(objSubFolder.FullName)
Next
End If
DeleteFolder(objFolder.FullName)
Return True
End If
Catch ex As Exception
Throw ex
End Try
End Function
but i have to show the progress bar during the files or folder
deletion.
so plz tell me what should i do.
i have a windows application. I am select the folder or file name
from the folderbrowserdialog box and to delete the folder or file i am
calling the following code.
Public Function DeleteFile(ByVal path As String) As Boolean
'Delete a specified file
Try
If File.Exists(path) = True Then
File.Delete(path)
Return True
End If
Catch ex As Exception
Throw ex
End Try
End Function
Public Function DeleteFolder(ByVal path As String) As Boolean
'Delete a specified folder
Dim objFileInfo As FileInfo
Dim objFolder As DirectoryInfo
Dim objSubFolder As DirectoryInfo
Dim dirInfo As DirectoryInfo = New DirectoryInfo(path)
Try
If Directory.Exists(path) = True Then
objFolder = New DirectoryInfo(path)
For Each objFileInfo In objFolder.GetFiles()
objFileInfo.Delete()
Next
If dirInfo.GetDirectories.Length = 0 Then
Directory.Delete(dirInfo.FullName)
Return True
Else
For Each objSubFolder In
objFolder.GetDirectories()
DeleteFolder(objSubFolder.FullName)
Next
End If
DeleteFolder(objFolder.FullName)
Return True
End If
Catch ex As Exception
Throw ex
End Try
End Function
but i have to show the progress bar during the files or folder
deletion.
so plz tell me what should i do.