473,651 Members | 3,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to show progress bar during the files or folders deletion

hi
i have a windows application. I am select the folder or file name
from the folderbrowserdi alog box and to delete the folder or file i am
calling the following code.

Public Function DeleteFile(ByVa l path As String) As Boolean
'Delete a specified file
Try
If File.Exists(pat h) = True Then
File.Delete(pat h)
Return True
End If
Catch ex As Exception
Throw ex
End Try
End Function

Public Function DeleteFolder(By Val 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(p ath)
Try
If Directory.Exist s(path) = True Then
objFolder = New DirectoryInfo(p ath)
For Each objFileInfo In objFolder.GetFi les()
objFileInfo.Del ete()
Next
If dirInfo.GetDire ctories.Length = 0 Then
Directory.Delet e(dirInfo.FullN ame)
Return True
Else
For Each objSubFolder In
objFolder.GetDi rectories()
DeleteFolder(ob jSubFolder.Full Name)
Next
End If
DeleteFolder(ob jFolder.FullNam e)
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.

Mar 29 '07 #1
1 5967
Hello Riky,

I see 2 options:

1. Show the Windows dialog for deleting the files or to put them into
the recycle bin:

Delete:
My.Computer.Fil eSystem.DeleteD irectory("C:\Th isPath",
FileIO.UIOption .AllDialogs, FileIO.RecycleO ption.DeletePer manently,
FileIO.UICancel Option.DoNothin g)

Recycle bin:
My.Computer.Fil eSystem.DeleteD irectory("C:\Th isPath",
FileIO.UIOption .AllDialogs, FileIO.RecycleO ption.SendToRec ycleBin,
FileIO.UICancel Option.DoNothin g)
2. Count files, delete them separately and increase the value for your
status dialog.

Best regards,

Martin

Riky wrote:
hi
i have a windows application. I am select the folder or file name
from the folderbrowserdi alog box and to delete the folder or file i am
calling the following code.

Public Function DeleteFile(ByVa l path As String) As Boolean
'Delete a specified file
Try
If File.Exists(pat h) = True Then
File.Delete(pat h)
Return True
End If
Catch ex As Exception
Throw ex
End Try
End Function

Public Function DeleteFolder(By Val 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(p ath)
Try
If Directory.Exist s(path) = True Then
objFolder = New DirectoryInfo(p ath)
For Each objFileInfo In objFolder.GetFi les()
objFileInfo.Del ete()
Next
If dirInfo.GetDire ctories.Length = 0 Then
Directory.Delet e(dirInfo.FullN ame)
Return True
Else
For Each objSubFolder In
objFolder.GetDi rectories()
DeleteFolder(ob jSubFolder.Full Name)
Next
End If
DeleteFolder(ob jFolder.FullNam e)
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.
Mar 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
12997
by: Raed Sawalha | last post by:
Dear, I have windows form , the form is using a class to do all tasks needed like this private void btnProcess_Click(object sender, System.EventArgs e) { btnProcess.Enabled = false; MailBoxRenamer oMailBox = new MailBoxRenamer(); //How Can i make the progress bar moving while rename processing is underway pBarCtrl.Visible = true; oMailBox.RenameAll();
7
2526
by: Steve Kallal | last post by:
I have seen this subject tossed around in this forum before. But in my case I need a simple solution. I do NOT need to show progress in terms on percentage complete. But rather I need to show a visual indicator to the user that a process is running. There are two scenarios where I need to show a busy indicator: Scenario #: The first is when posting to the web server and waiting for a response.
10
2918
by: Dan | last post by:
Hi - I'm about a week into learning VB.NET, and I'm finding I can't delete any of the VB.NET directory structures that contain my test projects I've been trying to create. I've never seen this before... Whenever I try, it says something like "access is denied" and "make sure the disk is not write-protected and file is not currently in use". Is there something VB.NET does that would cause this? I'm starting to build up a bunch of test...
3
3452
by: Tim Satterwhite | last post by:
Hi All, I think this is a thorny problem, and I'm hoping you can help. I've not found this exact issue described anywhere yet. I have a stored procedure that calls BULK INSERT on a set of text files. These files are FTP'd from a legacy system (a mainframe running MVS). Sometimes, the process steps on iteslf, whereby the bulk insert is attempted on a file whose FTP is still in progress; it's not fully written to disk on the SQL box...
6
2613
by: pankajprakash | last post by:
hi, i have a windows form and there is a text box to select the file of folder to delete. i need a progress bar during the file of folder deletion.
0
1855
by: remya1000 | last post by:
by using FTP i can send files to server using vb.net. if the file is big, then it will take some time to complete the sending process to server.or if we were sending 3-4 files to the server one by one,then whethere we can show the progress of each file sending to server in progress bar. so that the FTP clients can see the progress of file sending to the server. any idea how we can do this to show the progress of each file sending. if we...
2
2966
by: mcw.willart | last post by:
Hi, I use a backgroundworker to get the total size of a homeshare (as it is a bit time-consuming). Wat i would like to do, is show the progress, but at start i don't know how much files/folders will come up, so i dont't know how to feed the progressbar (i believe i need to know the maximum # of files to get a representative progress bar?). Anyone has any ideas?
2
3848
by: Jorgen Bodde | last post by:
Hi all, I want to make a small batch copy tool that scans for certain files, and copies them to a specified directory. Since the files are huge (AVI / DIVX) typical 300 to 700 Mb, I want to provide the user with some feedback during the file copy. Here is my dillemma; When I use shutil.move(..,..) I have to wait until it's done, there is no feedback, so the GUI basically hangs. However, shutil.move can be fast because it intelligently...
6
4969
by: kimiraikkonen | last post by:
Hi, I use system.io.file class to copy files but i have a difficulty about implementing a basic / XP-like progress bar indicator during copying process. My code is this with no progress bar, or i couldn't find sth which give totalbytes/written bytes class. And does system.io.file class provide awaring of the chunks / bytes of the files bytes which are written?
0
8278
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8584
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.