Hi this might sound weird, below is my VB Code
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
'Set fileapp = filesys.OpenTextFile("C:\TEST.txt", ForAppending, True)
Set filewrt = filesys.OpenTextFile("C:\TEXT.txt", ForWriting, True)
Set filesize = filesys.GetFile("C:\TEXT.txt")
filewrt.Write("HELOOO")
msgbox filesize.size
filewrt.close
This script shows the value ‘6’ for 6bytes as the file size in Windows 7 but in XP it shows 0 even though the file size is 6 bytes …. any ideas ?
EDIT:
I figured it out, had to close the file first and then display the filesize.size for XP to display the proper file size.
Still don’t know why this works on windows 7 … any thoughts ?
My best guess would be a change to file caching between the two versions of windows or the
FileSystemObjecthttp://msdn.microsoft.com/en-us/library/windows/desktop/aa364218%28v=vs.85%29.aspx
According to http://msdn.microsoft.com/en-us/library/z9ty6h50%28v=vs.84%29.aspx
So the XP version isn’t seeing the file size until the IO is flushed to the disk.