|
-
Oct 18th, 2008, 10:51 PM
#1
Thread Starter
Hyperactive Member
File Manipulation With Progress Bar (Move, Copy, Delete, Read, Write, etc)
Basically lets say my application needs to read a file or it needs to copy files around, move them etc... How can I link this with a progress bar to graphically display the "progress" of the operation?
Visual Basic Rules!!!!! 
-
Oct 18th, 2008, 11:54 PM
#2
Fanatic Member
Re: File Manipulation With Progress Bar (Move, Copy, Delete, Read, Write, etc)
Get the file size of the file using the FileLen() command. Then set the max length of the progress bar to the FileLen() file size. As the file is moved or copied adjust the progress bar accordingly.
-
Oct 19th, 2008, 08:50 PM
#3
Re: File Manipulation With Progress Bar (Move, Copy, Delete, Read, Write, etc)
Another option you have to use an Avi file while an operation is going on, that would be much simplier that using progress bar for those tasks...
Or that there is already a method of showing an animation while a file copy is in progress...
Code:
'Module:
Option Explicit
Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Const FO_COPY = &H2
Private Const FOF_ALLOWUNDO = &H40
Public Sub SHCopyFile(ByVal from_file As String, ByVal to_file As String)
Dim sh_op As SHFILEOPSTRUCT
With sh_op
.hWnd = 0
.wFunc = FO_COPY
.pFrom = from_file & vbNullChar & vbNullChar
.pTo = to_file & vbNullChar & vbNullChar
.fFlags = FOF_ALLOWUNDO
End With
SHFileOperation sh_op
End Sub
'Form
Private Sub Command1_Click()
'the following line will copy the file "d:\file.zip" to "d:\temp\file2.zip"
SHCopyFile "c:\dee-u.zip", "d:\dee-u.zip"
End Sub
-
Oct 19th, 2008, 09:24 PM
#4
Re: File Manipulation With Progress Bar (Move, Copy, Delete, Read, Write, etc)
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|