Dotinho Posted December 29, 2009 at 09:40 PM Report Share #303058 Posted December 29, 2009 at 09:40 PM Boa noite a todos, é o seguinte, fiz um programa para fazer backups, e para copiar ficheiros, uso a função my.filesystem.copyfile(). Só que fico chateado porque em ficheiros grandes, não me mostra a percentagem, então fiz o seguinte programinha. Private Sub FX_CopyFile(ByVal fo As String, ByVal fd As String, _ Optional ByVal Ff As F_SmartSync = Nothing) Dim sr1 As New IO.FileStream(fo, FileMode.Open) Dim sr2 As New IO.FileStream(fd, FileMode.CreateNew) Dim buff(1024) As Byte While sr1.Position < sr1.Length sr1.Read(buff, 0, 1023) sr2.Write(buff, 0, 1023) If Ff IsNot Nothing Then Ff.PA_Pb.Value = (sr1.Position / sr1.Length) * 99 Ff.PA_Lp.Text = Format(sr1.Position / sr1.Length, "00%") Ff.S_DoEvents() End If End While sr1.Close() sr2.Close() End Sub Mas não sei porque, em alguns ficheiros diz: Acesso negado ao ficheiro! (isto é uma mensagem ex.message) Outra coisa que não sei fazer, é passar as propriedades entre o ficheiro novo e o original, do tipo gostava de passar a data de modificação, para comparar se houve alteração ou não.. Penso que seja porcausa do windows 7, mas nao sei... Luis Lourenço Link to comment Share on other sites More sharing options...
scorch Posted December 29, 2009 at 09:54 PM Report Share #303064 Posted December 29, 2009 at 09:54 PM Tenta, ao executar o programa, clicar com o direito sobre o ficheiro e correr como administrador. PS: Não respondo a perguntas por mensagem que podem ser respondidas no fórum. Link to comment Share on other sites More sharing options...
Dotinho Posted December 29, 2009 at 09:59 PM Author Report Share #303067 Posted December 29, 2009 at 09:59 PM Pois, infelizmente, da o mesmo erro.. B) É engraçado que já tentei usar strems, em outras funções e da na mesma o erro. Luis Lourenço Link to comment Share on other sites More sharing options...
Dotinho Posted December 29, 2009 at 10:14 PM Author Report Share #303082 Posted December 29, 2009 at 10:14 PM Obrigado, mas já deu... eu mostro como dá: Private Sub FX_CopyFile(ByVal fo As String, ByVal fd As String, _ Optional ByVal Ff As F_SmartSync = Nothing) Dim foi = New FileInfo(fo) Dim fdi = New FileInfo(fd) Dim sr1 = foi.OpenRead Dim sr2 = fdi.OpenWrite Dim buff(2048) As Byte While sr1.Position < sr1.Length sr1.Read(buff, 0, 1048) sr2.Write(buff, 0, 1048) If Ff IsNot Nothing Then Ff.PA_Pb.Value = (sr1.Position / sr1.Length) * 99 Ff.PA_Lp.Text = Format(sr1.Position / sr1.Length, "00%") Ff.S_DoEvents() End If End While sr1.Close() sr2.Close() fdi.LastWriteTime = foi.LastWriteTime End Sub Luis Lourenço Link to comment Share on other sites More sharing options...
Dotinho Posted December 29, 2009 at 10:15 PM Author Report Share #303084 Posted December 29, 2009 at 10:15 PM Desculpem a pergunta, mas nao falta um botão a dizer resolvido ou assim coisa do genero? Luis Lourenço Link to comment Share on other sites More sharing options...
scorch Posted December 29, 2009 at 10:18 PM Report Share #303086 Posted December 29, 2009 at 10:18 PM Esse plugin, como ainda não tem nenhuma versão compatível com a versão actual do fórum, foi temporariamente removido. PS: Não respondo a perguntas por mensagem que podem ser respondidas no fórum. Link to comment Share on other sites More sharing options...
Dotinho Posted December 29, 2009 at 10:22 PM Author Report Share #303089 Posted December 29, 2009 at 10:22 PM Pronto, obrigado pela explicação...Assim como as imagens (http://www.portugal-a-programar.org/forum/Themes/BlackRain_RC/images/starblack.gif) junto ao nome, tambem nao funcionam.. Boa noite a todos e boa continuação B) Luis Lourenço 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