Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to get a file's modified date/time and size in bytes?
#16
(05-22-2024, 06:20 PM)madscijr Wrote:
(05-22-2024, 05:04 PM)SpriggsySpriggs Wrote: I guess I'm going to have to become the old geezer who complains that everyone is ruining hard drives with temp files constantly.
Ha! 

Well in this case I was looking to see if a file changed on disk, and only access it if it changed. 
I figured looking at the timestamp and size in bytes are a good way to tell. 
The problem with using this SHELL method that creates a file is, it requires at least 3 disk accesses: 
  1. one to read the attributes
  2. one to write them to a temp file, and 
  3. one to read that file 
  4. (and another if we want to delete the temp file)

Not too efficient. For a lot of cases that might not be a big deal, but for what I'm doing, it would slow things down a lot.

We have a thread somewhere to suggest new commands for QB64PE, right? Where can I suggest adding some built-in cross-platform commands to get a file's date / size / attributes (& maybe update them as well)?
Note that you can use wmic to get all sorts of attribute information on your files, easily from the command line:

Code: (Select All)
AccessMask=1507775
Archive=FALSE
Caption=Z:\foo.pdf
Compressed=TRUE
CompressionMethod=Compressed
CreationClassName=CIM_LogicalFile
CreationDate=20240518233126.540393-240
CSCreationClassName=Win32_ComputerSystem
CSName=LAPTOP
Description=Z:\foo.pdf
Drive=z:
EightDotThreeFileName=z:\foo.pdf
Encrypted=FALSE
EncryptionMethod=
Extension=pdf
FileName=foo
FileSize=34339
FileType=pdf File
FSCreationClassName=Win32_FileSystem
FSName=NTFS
Hidden=FALSE
InstallDate=20240518233126.540393-240
InUseCount=
LastAccessed=20240522175359.607566-240
LastModified=20240501171800.893675-240
Manufacturer=
Name=Z:\foo.pdf
Path=\
Readable=TRUE
Status=OK
System=FALSE
Version=
Writeable=TRUE
All from this simple program: 
Code: (Select All)
$Console:Only
Shell "wmic DataFile where " + Chr$(34) + "Name='Z:\\foo.pdf'" + Chr$(34) + " list /format:list"
Reply


Messages In This Thread
RE: how to get a file's modified date/time and size in bytes? - by SMcNeill - 05-22-2024, 10:03 PM



Users browsing this thread: 11 Guest(s)