Function to check whether an object is a File object and whether the file exists on the file system.
To check whether a resource is a file object:
var file = new File("C:/myfile.txt"); if(isFile(file)) { //Do something is this is a file object }
To check whether the resource is a file object and that the file exists on the file system:
var file = new File("C:/myfile.txt"); if(isFile(file, true)) { //Do something is this is a file object and if the file exists on the file system }
Parameter | Data type | Required | Description |
---|---|---|---|
file | all | Yes | The object to check. You can parse any kind of object, string or variable to this function |
mustexist | boolean | If set to true the function also checks that the file exists on the file system. Default is false |
Value | Meaning |
---|---|
true | The specified object is a file object. When the parameter mustexist is set to true , this return value also means that the file exists on the file system |
false | The specified object is not a file object. When the parameter mustexist is set to true , this return can also mean that the file does not exist on the file system even when the object is a file object |