Hi,
I saw in a lot of examples and in the documentation as well, that when I want to know the file size in VBScript, I use f.size. Howeever, when I use it in my script, it gives an error.
The code is like this:
Dim fso, f, idxLet
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filename, ForReading)
MsgBox f.size
The error generated:
438 Object doesn't support this property or method 'f.size'.
Why is that?
Thank you,
Olga.
Why f.size doesn't work? (VBScript)
Moderators: JRL, Dorian (MJT support)
For a TextStream, f.close should be fine for what you are doing, even if further down in the script you "Set f" as another object/file.
If it's a folder/file used by GetFile, you don't need to "close" it. You can continue to "Set f" as another object/file.
If you're concerned about your script running for a long time, and using too many resources, you can indeed:
Set f = Nothing
If it's a folder/file used by GetFile, you don't need to "close" it. You can continue to "Set f" as another object/file.
If you're concerned about your script running for a long time, and using too many resources, you can indeed:
Set f = Nothing
Thank you, Captive,
Do you know may be if when I exit from a function, it's best if I do Set f Nothing, or it doesn't matter? I mean, if I exit a function, all the resources allocated to it should be freed right?
I ask because for example in JScript I read that even though assigning a new timeOut to a timer should free the old timer, it doesn't always happen (a bug), and thus it's better to always first clear the old timer first and only then to assign a new.
Thank you,
Olga.
Do you know may be if when I exit from a function, it's best if I do Set f Nothing, or it doesn't matter? I mean, if I exit a function, all the resources allocated to it should be freed right?
I ask because for example in JScript I read that even though assigning a new timeOut to a timer should free the old timer, it doesn't always happen (a bug), and thus it's better to always first clear the old timer first and only then to assign a new.
Thank you,
Olga.