Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 21st, 2003, 09:13 AM
linh linh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 245 linh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 27 sec
Reputation Power: 6
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

Reply With Quote
  #2  
Old November 21st, 2003, 10:32 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
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

Reply With Quote
  #3  
Old November 23rd, 2003, 01:29 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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!!..

Reply With Quote
  #4  
Old November 24th, 2003, 12:41 PM
linh linh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 245 linh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 27 sec
Reputation Power: 6
reply

Thank you Fisherman and cleverpig.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Measure how much Kilobytes I have left to copied to a drive


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT