Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Size question

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
I have an app that has a file list pointed to a directory and the pattern is set to *.wav.

A timer runs every 30 seconds.

When the timer goes off, I want to check the filesize of the wave files in the directory and if the size is the same after wo consecutive checks, I can then perform actions on the file (I will then know the entire file has been received).

Can someone help me use the GetFileSize()? and how can I check to make sure it is the same with two consecutive checks (timer calls) for each file in the directory?

Thanks.
fergmj
 
Hello fergmj,

You can use a two dimensional dynamic array. The first column will keep the filename and the second the size of the array at the last check.

In order to use the GetFileSize API Call i would suggest the Those guys are great! the have a program called API-Guid that contains more thatn 750 API calls (yes there is an example for the GetFileSize :) ) and examples in Visual Basic. It worth downloading it

I hope that this helped you "The Camel will walk the desert of programming once again ..."

Camel
 
I am using the FileSystemObject mentioned by John Yingling.

Here is what I did: (and this worked)

Dim fso As New FileSystemObject
Dim f As File
File1.Refresh
For gogo = 0 To File1.ListCount - 1 ' loop for all file names
Set f = fso.GetFile("C:\apfiles\output\audio\01114151.wav")
MsgBox (f) ' just wanted to see the filename
MsgBox (f.Size) ' just wanted to see the size of the file


What didn't work was.....
In the Set f line, if I Set f = fso.GetFile(File1.List(gogo))
I get a "File Not Found" error

I have a fileList Box with several wav files. I want to check the size of the file every 30 secs.

How can I iterate through the list of files and set a two dimensional array with the filename and size?

Thanks

fergmj

 
After reading thread222-12899 I went to the FileLen and I am not having any problems getting the size of the file. Still the issue is how to store the size in a two dimensional array.

fergmj
 
Does your file list box have the full path name with the file name? Also, I use ON ERROR when messin' with files
Code:
Dim strResponse as string
Dim strFilename as string
On error resume next
    strFilename = File1.List(gogo) ' Save for MsgBox
    strFilename = fso.BuildPath(strpath, strFileName)
    Set f = fso.GetFile(strFileName)
    if Err.Number > 0 then strResponse = err.Description
On Error goto 0
If Len(strResponse) > 0 then 
    lngResult = MsgBox(strResponse & vbCrlf & strFileName, _
                vbCritical + vbOKCancel)
    if lngResult = vbCancel then exit sub
else
    ..... process file
end if

 
John -

I bailed out on the FileSystemObject

I have gone with the FileLen

I have a list of files and a file size. I need to iterate through the list and make an array with the filename and filesize for each.

Can you help?

Thanks

fergmj
 
Code:
'Two Arrays
Dim arystrFileName() as string
Dim aryLngFilesize() as string
Dim lngCount as long
Dim I as long
lngCount = list.listcount
'* start at 1 in array so we still have an array
'* even if 0 items
Redim aryStrFileName(lngCount)
Redim arylngFileSize(lngcount)
For I = 1 to lngcount
    aryFilename(I) = list.item(I-1)
    arylngFilesize(I) = 'wherever your filesize is
Next
'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top