|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Measure how much Kilobytes I have left to copied to a drive
Below is the API call to copied a number of files to the directory. I copied fine, but as it copied a file I would like to do the following:
1) Display on a text box the name of the file that it currently copied. 2) Display the total amount of Kilobytes that it have already written to a C:\ drive and the remaining amount Kilobytes that is has to be written. A better statement would be to display the remaining time it takes to copied the remaining amount of kilobytes. I intend to have it display as a progress bar. Some solution to this problem is to time how long it will take to write to a drive and then use a timer to mark the progress bar. This is not an accurate way to measure how much there is left to copied a total number of say 1 Megabytes of files. Since each hard drive write speed is different, whether the particular hard drive had been defrag, how much application is opened at the time of copying, whether the same files has been cached into the RAM. All these and many other factors means that writing to a files might take more time or less time and it varied from computer to computer. Therefore, the only way to measure how long it takes to copy files is to measure how much Kilobytes there is left to write in light of the total sizes of all the files that you intend to copy. How do I achieved question number 2 ? Project --> References --> Microsoft Scripting Runtime ==================================== Code:
Private Sub Copy_Files_To_The_Hard_Drive()
On Error GoTo ErrorHandler
Dim File_String As String
Dim Source_File_Path As String
Dim Error_Exist As Boolean
Dim Destination_File_Path As String
Dim fso As Scripting.FileSystemObject
Error_Exist = False
Set fso = New Scripting.FileSystemObject
Source_File_Path = "a:\testing\*.*"
Destination_File_Path = Directory_Box
fso.CopyFile Source_File_Path, Destination_File_Path
If Error_Exist Then
MsgBox "No files have been copied to " & Directory_Box
Else
MsgBox "All files have been copied to " & Directory_Box
End If
ErrorHandler:
Select Case Err.Number ' Evaluate error number.
Case 53
Error_Exist = True
'MsgBox "File ipsec.conf does not exist on C:\"
Case 55 ' "File already open" error.
Error_Exist = True
Close #1 ' Close open file.
Case 71
Error_Exist = True
MsgBox "The floppy disk is not in the disk drive.
Please insert the installation disk into
the A drive", vbInformation
Case Else
' Handle other situations here...
End Select
Resume Next
End Sub
|
|
#2
|
||||
|
||||
|
There is a method of the File System Object called
YOURFSO.GetDrive.AvailableSpace that should work fine
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
|||
|
|||
|
I think it's a way that u can get the copy source files's total size and set it to the process bar's max value.When u copied a file, u can increase the process bar's value by adding this file's size!
See http://msdn.microsoft.com/library/d...objectmodel.asp to get more special detail message about filesystem object!!.. |
|
#4
|
|||
|
|||
|
reply
Thank you Fisherman and cleverpig.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Measure how much Kilobytes I have left to copied to a drive |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|