estica Posted November 18, 2015 at 11:31 PM Report Share #589868 Posted November 18, 2015 at 11:31 PM 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 More sharing options...
He B TeMy Posted November 18, 2015 at 11:45 PM Report Share #589869 Posted November 18, 2015 at 11:45 PM http://stackoverflow.com/a/6055385/2990244 Tenta modificar o teu código de modo a que não uses application.doevents... 1 Report Link to comment Share on other sites More sharing options...
estica Posted November 19, 2015 at 06:02 PM Author Report Share #589903 Posted November 19, 2015 at 06:02 PM (edited) 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 November 19, 2015 at 06:41 PM by estica Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now