I have a .7z file that always has problems when I try to copy the file via code. This happens with every .7z file that I have tested with. Therefore, I have written the following code to keep repeating a file copy function until the filesize of the destination file matches the size of the source file. However, I think this is getting caught in an endless loop. FYI, file MYFILE.7z already exists on both the source and the destination. The code below is a routine that is executed after the file is in both places to verify that the file actually copies successfully to the destination.
And here is the declared function I am using for GetFileSize:Code:Public Sub Load_BackupFile() Dim Device As String Dim Source7z As Long Dim Dest7z As Long Device = Trim(frmmain.cmbDriveSelect.Text) 'get the file size of the .7z file in the build directory & on the Device source7z = GetFileSize("C:\MYFILE.7z") Dest7z = GetFileSize(frmmain.cmbDriveSelect.Text & "MYFILE.7z") While Dest7z <> Source7z System.IO.File.Copy("C:\MYFILE.7z", Device & "MYFILE.7z", True) End While End Sub
Thanks for any help with this one.Code:Public Function GetFileSize(ByVal MyFilePath As String) As Long Dim MyFile As New FileInfo(MyFilePath) Dim FileSize As Long = MyFile.Length Return FileSize End Function
-Jeremy




Reply With Quote