The problem is that you perform the method
GetFile() but you don't assign the returned
file object to a variable.
And the
Size property is a member of a
file object, not a member of a
file system object.
Thus:
code:
var fileso = new ActiveXObject("Scripting.FileSystemObject");
var file = fileso.GetFile("C:\\dp.jpg");
MsgPlus.DisplayToast("UnionRo 2.0","FileSize: " + file.Size);
Also note that the code doesn't take in account file errors which may occur. eg: if the file "C:\\dp.jpg" doesn't exist for example.
So better would be:
code:
var fileName = "C:\\dp.jpg";
var fileSystemObject = new ActiveXObject("Scripting.FileSystemObject");
if (fileSystemObject.FileExists(fileName)) {
var fileObject = fileSystemObject.GetFile(fileName);
MsgPlus.DisplayToast("UnionRo 2.0","FileSize: " + fileObject.Size);
} else {
MsgPlus.DisplayToast("UnionRo 2.0","File does not exist");
}
and made a bit shorter:
code:
var fileName = "C:\\dp.jpg";
var fileSystemObject = new ActiveXObject("Scripting.FileSystemObject");
if (fileSystemObject.FileExists(fileName)) {
MsgPlus.DisplayToast("UnionRo 2.0","FileSize: " + GetFile(fileName).Size);
} else {
MsgPlus.DisplayToast("UnionRo 2.0","File does not exist");
}