FolderItem.Length should return the actual file size. I wonder if perhaps your “empty” file is not empty? For example, on Windows a blank line is encoded as 2 bytes (CR + LF). Perhaps that’s what you are seeing?
What does Windows say the lengths are? And what type of encoding are they? An empty UTF-8 file will probably be 3 bytes while a Unicode file will probably be 2 bytes, plus whatever the text editor program left behind.
If you created the file with WordPad, as it is not pure ASCII, that would make sense. Although you enter only one character, the RTF header takes room. Did you compare what the properties of the file tell you as opposed to FolderItem.Length ?
A nice application to create really small ASCII files is Notepad.
Good point, Dale. I’ve never used that as I tend to live at the command line with unxutils (my real command would have been “touch Somefile.txt”) or in my games (Diablo III Reaper of Souls hits tomorrow!). I never found enough of a use for Explorer to take it farther than “Double-Click to start” or to find a file and Windows 8.1 has even removed that requirement :). I do believe that I’ve used “New Folder” a few times, but hadn’t even noticed the “New File Type” options.
If you like to use OLEObject, you can do following.
Dim fileSpec As String = "c:\\temp\\test.txt"
Dim oFSO AS OLEObject
Dim oGFO As OLEObject
Dim fileName As String
Dim fSize As UInt64
oFSO = New OLEOBJECT("Scripting.FileSystemObject")
If (oFSO.FileExists(filespec)) Then
fileName = oFSO.GetFileName(filespec)
oGFO = oFSO.GetFile(filespec)
fSize = oGFO.size
Msgbox("FileName " + fileName + " uses " + str(fSize) + " bytes")
Else
msgbox(filespec + " doesn't exist.")
End If
oFSO = Nil
exception err as oleexception
msgbox err.message