|
-
Jul 9th, 2004, 02:42 AM
#1
Thread Starter
Addicted Member
Waiting for file, check filesize then process... Help please
I've written this little prog that will check for a file.
If a file is found then will check the file size then pause, check the file size again and compaire the two. If the file size is same then process file else wait .
If anyone can help, would be great.
VB Code:
Dim FSO As New FileSystemObject 'set fso as new file system object
Dim Filen As File 'This is a file
Dim FileLena, FileLenb As Long
If File1.ListCount = 0 Then
FileName = File1.FileName
Do Until FileLena = FileLenb
Set Filen = FSO.GetFile(FileName) 'Set fullstring as full filename and pick the file
FileLena = Filen.Size 'Get file size
Text1.Text = Filen.Size 'display the filesize in text box 1
Wait 1 'wait 1 seconds
FileLenb = Filen.Size 'Get file size
Text2.Text = Filen.Size 'display the filesize in text box 2
Wait 1
Loop
-
Jul 9th, 2004, 03:31 AM
#2
Hyperactive Member
I dont get it what is your question here ?
Born to help others
(If I've been helpful then please rate my post. Thanks)
call me EJ or be slapped! 
-
Jul 9th, 2004, 03:35 AM
#3
Thread Starter
Addicted Member
I'm trying to check the size of a file, if filesize is the same then carry on else wait 1.
When I run this, it dosn't seem to work... just waits and skips.
Does this help??
-
Jul 9th, 2004, 04:24 AM
#4
Re: Waiting for file, check filesize then process... Help please
I don't use FSO myself, it adds too much overhead for simple tasks like this.
The FileLen function is easily enough in this case:
VB Code:
Dim FileLena [b]as Long[/b], FileLenb As Long 'FileLena was a variant as you did it ;)
[b]If File1.ListCount = 0 Then 'erm... this seems like a problem![/b]
FileName = File1.FileName
Do
FileLena = FileLen(FileName) 'Get file size
Text1.Text = FileLena 'display the filesize in text box 1
Wait 1 'wait 1 seconds
FileLenb = FileLen(FileName) 'Get file size
Text2.Text = FileLenb 'display the filesize in text box 2
Wait 1
Loop [b]Until FileLena = FileLenb [/b] 'you want the code to run at least once, so this needs to go at the end
-
Jul 9th, 2004, 04:46 AM
#5
Add this to a timer event I think it should work
VB Code:
Private Function FileSizeChanged(ByVal filename As String) As Boolean
Dim RetVal As Boolean
Static lngSize As Long
If lngSize <> FileLen(filename) Then
RetVal = True
Else
RetVal = False
End If
FileSizeChanged = RetVal
End Function
-
Jul 12th, 2004, 10:00 AM
#6
Thread Starter
Addicted Member
I've been trying this for sometime and working great. But when I get a large file that gets copied over the network, it fails.
It tries to use the file before the 'true' file size is the same.
I could get my program to wait a number of seconds but my only fear is that one day it will try and process a file that's still being copied.
Any one got any ideas?
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
|