By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,830 Members | 2,182 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,830 IT Pros & Developers. It's quick & easy.

Simplest way to read size of file on disk from Access 2.0 code?

P: n/a
MLH
I want to be able to read the file
size of my config.sys file or other
file from withing Access Basic
module. I'm sure its already been
done. Don't wanna reinvent wheel
or lug nuts, etc.
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I don't believe Access 2.0 had the FileLen function that subsequent version
have. I think there was an API call that could do it, but unfortunately I
don't have a 16 bit API reference anymore.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"MLH" <CR**@NorthState.net> wrote in message
news:ed********************************@4ax.com...
I want to be able to read the file
size of my config.sys file or other
file from withing Access Basic
module. I'm sure its already been
done. Don't wanna reinvent wheel
or lug nuts, etc.

Nov 13 '05 #2

P: n/a
MLH
<snip>
I don't believe Access 2.0 had the FileLen function that subsequent version
have. I think there was an API call that could do it, but unfortunately I
don't have a 16 bit API reference anymore.


Darn. Just my luck. I looked all through the TA Code Tools. If there
had been an API fn call to return something line FileLen in the 16-bit
library - they would probably have know it. I suppose I'll have to
rely on some junky way like running a command line...

dir c:\mydir\thisfile.txt > 1234567890.txt

then pull in 1234567890.txt & parse it out. THat's about the suckiest
way I can think of to do it. Maybe that's all there was.
Nov 13 '05 #3

P: n/a
MLH
<SNIP>
I don't believe Access 2.0 had the FileLen function that subsequent version
have. I think there was an API call that could do it, but unfortunately I
don't have a 16 bit API reference anymore.


xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Well, even a blind hog...

Open "c:\mydir\data.fil" For Binary As #1
FileSize = LOF(1)
Close #1
MsgBox CStr(FileSize)

Nov 13 '05 #4

P: n/a
MLH
>I don't believe Access 2.0 had the FileLen function that subsequent version
have. I think there was an API call that could do it, but unfortunately I
don't have a 16 bit API reference anymore.


xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Well, even a blind hog can find an acorn sometimes...

Open "c:\mydir\data.fil" For Binary As #1
FileSize = LOF(1)
Close #1
MsgBox CStr(FileSize)

Nov 13 '05 #5

P: n/a
MLH wrote:
I don't believe Access 2.0 had the FileLen function that subsequent version
have. I think there was an API call that could do it, but unfortunately I
don't have a 16 bit API reference anymore.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Well, even a blind hog can find an acorn sometimes...

Open "c:\mydir\data.fil" For Binary As #1
FileSize = LOF(1)
Close #1
MsgBox CStr(FileSize)


You'd best check it exists first with the Dir() function as opening in
binary mode will create the file if it doesn't and return 0 bytes,
either that or open the file for input.

Another tip is that some other process may have the file open, since all
you want to do is get the size of the file that shouldn't bother you but
the i/o open command opens it with an exclusive lock unless otherwise
specified, e.g.
open "file" for binary access read shared as #1

Bummer if the file is over 2GB though :-)

--
[Oo=w=oO]

Nov 13 '05 #6

P: n/a
MLH
<snip>
You'd best check it exists first with the Dir() function as opening in
binary mode will create the file if it doesn't and return 0 bytes,
either that or open the file for input.

Another tip is that some other process may have the file open, since all
you want to do is get the size of the file that shouldn't bother you but
the i/o open command opens it with an exclusive lock unless otherwise
specified, e.g.
open "file" for binary access read shared as #1

Bummer if the file is over 2GB though :-)


Thx Trevor. I read the filesize immediately after creating the binary,
logging its (ever growing) size into an archive table.
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.