|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Programmatically Determining File Size and/or contentsI have a VB6 program that I need to make modifications to so that it can
determine the file size of a txt file that is downloaded to a folder (by a separate process). This other process will put the file in this location whether or not it has any records in it. Is there a way to programmitically determine if the file is empty, so as I can skip trying to read and process an empty file? Thanks "Rob" <R**@discussions.microsoft.com> wrote in message See FindFirstChangeNotification() in MSDN. Here is a VB6 sample:news:02785FD4-D0CA-4074-81F5-2FC3BE8EFF23@microsoft.com... >I have a VB6 program that I need to make modifications to so that it can > determine the file size of a txt file that is downloaded to a folder (by a > separate process). This other process will put the file in this location > whether or not it has any records in it. Is there a way to > programmitically > determine if the file is empty, so as I can skip trying to read and > process > an empty file? http://vbnet.mvps.org/code/fileapi/watchedfolder.htm "Rob" <R**@discussions.microsoft.com> wrote in message A truly empty TEXT file will have no characters, and therefore zero bytes, news:02785FD4-D0CA-4074-81F5-2FC3BE8EFF23@microsoft.com... >I have a VB6 program that I need to make modifications to so that it can > determine the file size of a txt file that is downloaded to a folder (by a > separate process). This other process will put the file in this location > whether or not it has any records in it. Is there a way to > programmitically > determine if the file is empty, so as I can skip trying to read and > process > an empty file? > no? That being the case, FileLen would appear to give you what you want: the size of the file in bytes, and if zero, an empty file. -- Regards, Rick Raisley heavymetal-A-T-bellsouth-D-O-T-net FileLen is limited to Long, so will fail for large files.
Show quoteHide quote "Rick Raisley" wrote: > "Rob" <R**@discussions.microsoft.com> wrote in message > news:02785FD4-D0CA-4074-81F5-2FC3BE8EFF23@microsoft.com... > >I have a VB6 program that I need to make modifications to so that it can > > determine the file size of a txt file that is downloaded to a folder (by a > > separate process). This other process will put the file in this location > > whether or not it has any records in it. Is there a way to > > programmitically > > determine if the file is empty, so as I can skip trying to read and > > process > > an empty file? > > > > > A truly empty TEXT file will have no characters, and therefore zero bytes, > no? That being the case, FileLen would appear to give you what you want: the > size of the file in bytes, and if zero, an empty file. > > -- > Regards, > > Rick Raisley > heavymetal-A-T-bellsouth-D-O-T-net > > > In article <E5AB7610-62CF-4802-9B91-696AC8301***@microsoft.com>,
B**@discussions.microsoft.com says... > FileLen is limited to Long, so will fail for large files. Hopefully he's not d/l'ing files over 2GB. What does FileLen() return for files larger than that? As long as it's not zero, he should be ok, even if he needs to trap an exception. ..... -- /~\ The ASCII \ / Ribbon Campaign X Against HTML / \ Email! Remove the ns_ from if replying by e-mail (but keep posts in the newsgroups if possible). Right. A test on a 6 GB file gave a FileLen of 1873608704 (with no error),
and a FileLen of 1873608704 on a 207 GB file, so if the OP is just trying to determine if a file is empty or not, that would certainly work. As the FileLen given is some residual, and not the actual file size, it is possible that every 2GB or so there is a precise file size that would fail and evaluate to 0. But between the huge size, and the slim chances of that happening, he can probably chance it. ;-) -- Show quoteHide quoteRegards, Rick Raisley heavymetal-A-T-bellsouth-D-O-T-net "David Kerber" <ns_dkerber@ns_WarrenRogersAssociates.com> wrote in message news:MPG.248decd5324d6c3f989d19@news.conversent.net... > In article <E5AB7610-62CF-4802-9B91-696AC8301***@microsoft.com>, > B**@discussions.microsoft.com says... >> FileLen is limited to Long, so will fail for large files. > > Hopefully he's not d/l'ing files over 2GB. What does FileLen() return > for files larger than that? As long as it's not zero, he should be ok, > even if he needs to trap an exception. > > .... > > -- > /~\ The ASCII > \ / Ribbon Campaign > X Against HTML > / \ Email! > > Remove the ns_ from if replying by e-mail (but keep posts in the > newsgroups if possible). > True, but a 2+ GB limit will read most/many files. Nothing was said by the
OP that these were huge data files. -- Show quoteHide quoteRegards, Rick Raisley heavymetal-A-T-bellsouth-D-O-T-net "Bee" <B**@discussions.microsoft.com> wrote in message news:E5AB7610-62CF-4802-9B91-696AC8301945@microsoft.com... > FileLen is limited to Long, so will fail for large files. > > > "Rick Raisley" wrote: > >> "Rob" <R**@discussions.microsoft.com> wrote in message >> news:02785FD4-D0CA-4074-81F5-2FC3BE8EFF23@microsoft.com... >> >I have a VB6 program that I need to make modifications to so that it can >> > determine the file size of a txt file that is downloaded to a folder >> > (by a >> > separate process). This other process will put the file in this >> > location >> > whether or not it has any records in it. Is there a way to >> > programmitically >> > determine if the file is empty, so as I can skip trying to read and >> > process >> > an empty file? >> > >> >> >> A truly empty TEXT file will have no characters, and therefore zero >> bytes, >> no? That being the case, FileLen would appear to give you what you want: >> the >> size of the file in bytes, and if zero, an empty file. >> >> -- >> Regards, >> >> Rick Raisley >> heavymetal-A-T-bellsouth-D-O-T-net >> >> >> "Bee" <B**@discussions.microsoft.com> wrote in message I think Randy's site has an API version which will handle > 2GB. news:E5AB7610-62CF-4802-9B91-696AC8301945@microsoft.com... > FileLen is limited to Long, so will fail for large files. http://vbnet.mvps.org.
PictureBox Scale Confusion
What files should I distribute (SAPI 5.3)? How to test for array? DLL in Visual BASIC 6 Mayayana and others: Know The Notes now for 98SE using MM's new 'Never Replace' scheme regfree-loading WMI and WIN2003 Finding the biggest number out of 8 variables 100% quandry Print # vs .Savefile |
|||||||||||||||||||||||