Jump to content

Progressebar delete file


estica
 Share

Recommended Posts

Uso o seguinte código para fazer o progressbar funcionar ao copiar um ficheiro ou uma pasta...

Agora queria saber como faço o mesmo procedimento mas para apagar pasta ou file

Dim CF As New IO.FileStream("PASTA", IO.FileMode.Open)
Dim CT As New IO.FileStream("PATAS", IO.FileMode.Create)
Dim len As Long = CF.Length - 1
Dim buffer(1024) As Byte
Dim byteCFead As Integer
While CF.Position < len
byteCFead = (CF.Read(buffer, 0, 1024))
CT.Write(buffer, 0, byteCFead)
ProgressBar2.Value =
CInt(CF.Position / len * 100)
Application.DoEvents()
End While
CT.Flush()
CT.Close()
CF.Close()
Link to comment
Share on other sites

Já foi uma boa ajuda amigo. Vou ver então como fazer

EDIT:

Como adaptar este código no Vb.net

If Directory.Exists(source) Then

Dim fileEntries As String() = Directory.GetFiles(source)

' Initializing progress bar properties

progressBarControl1.Properties.Step = 1

progressBarControl1.Properties.PercentView = True

progressBarControl1.Properties.Maximum = fileEntries.Length

progressBarControl1.Properties.Minimum = 0

' Removing the list of files found in the specified directory

For Each fileName As String In fileEntries

File.Delete(fileName)

progressBarControl1.PerformStep()

progressBarControl1.Update()

Next fileName

End If

End Sub

Edited by estica
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.