Lecture de n'importequel fichier en binaire

Résolu
Vertefeuille Messages postés 19 Date d'inscription dimanche 9 janvier 2005 Statut Membre Dernière intervention 20 janvier 2007 - 19 août 2005 à 13:33
BasicInstinct Messages postés 1470 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 20 octobre 2014 - 19 août 2005 à 21:16
Bonjour à tous,

Voilà mon problème : j'aimerai copier un fichier et visualiser la progression de l'écriture du fichier sur le disque. Il y a bien une technique mais elle est en .NET et en vb6 il y a bien Seek ou Loc mais il faut un numéro de fichier "ouvert". Vu que je n'ouvre aucun fichier (c'est juste une copie), ça me serre à rien.

Quelqu'un aurait-il une solution ?

Merci

3 réponses

BasicInstinct Messages postés 1470 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 20 octobre 2014 12
19 août 2005 à 14:16
directement sorti de l'api guide


'in a form (Form1)


Private Sub Form_Load()


'KPD-Team 2001


'URL: http://www.allapi.net/


'E-Mail: KPDTeam@Allapi.net


Dim Ret As Long


'set the graphics mode to persistent


Me.AutoRedraw = True


'print some text


Me.Print "Click the form to abort the filecopy"


'show the form


Me.Show


'start copying


Ret = CopyFileEx("c:\verybigfile.ext", "c:\copy.ext", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)


'show some text


Me.Print "Filecopy completed " + IIf(Ret = 0, "(ERROR/ABORTED)", "successfully")


End Sub


Private Sub Form_Click()


'cancel filecopy


bCancel = 1


End Sub


'in a module


Public Const PROGRESS_CANCEL = 1


Public Const PROGRESS_CONTINUE = 0


Public Const PROGRESS_QUIET = 3


Public Const PROGRESS_STOP = 2


Public Const COPY_FILE_FAIL_IF_EXISTS = &H1


Public Const COPY_FILE_RESTARTABLE = &H2


Public Declare Function CopyFileEx Lib "kernel32.dll" Alias "CopyFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As Long, lpData As Any, ByRef pbCancel As Long, ByVal dwCopyFlags As Long) As Long


Public bCancel As Long


Public Function CopyProgressRoutine(ByVal TotalFileSize As Currency, ByVal TotalBytesTransferred As Currency, ByVal StreamSize As Currency, ByVal StreamBytesTransferred As Currency, ByVal dwStreamNumber As Long, ByVal dwCallbackReason As Long, ByVal hSourceFile As Long, ByVal hDestinationFile As Long, ByVal lpData As Long) As Long


'adjust the caption


Form1.Caption = CStr(Int((TotalBytesTransferred * 10000) / (TotalFileSize * 10000) * 100)) + "% complete..."


'allow user input


DoEvents


'continue filecopy


CopyProgressRoutine = PROGRESS_CONTINUE


End Function

++

BasicInstinct
3
Vertefeuille Messages postés 19 Date d'inscription dimanche 9 janvier 2005 Statut Membre Dernière intervention 20 janvier 2007
19 août 2005 à 20:58
C'est parfait, merci beaucoup. C'est exactement ce que je cherchais.

Encore merci
0
BasicInstinct Messages postés 1470 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 20 octobre 2014 12
19 août 2005 à 21:16
valide la reponse, ca accelera les recherches des autres, svp

BasicInstinct
0
Rejoignez-nous