Checking the Existance of a file?

Hi,
i am just checking the existance of a file under some location.
But how i will create a JSFile Object of the specified file.

There is a method :-

plugins.file.convertToJSFile();

But It is not working or otherwise i am not getting properly about it’s argement.

Any Help to solve the above problem?

A JSFile is a wrapper object for the java.io.File. Convert to JSFile takes a path name as String and returns a JSFile. So you should be able to do (out of my head, so there might be typo errors):

var myPath = 'C:\\Test.xls'
var jsFile = plugins.file.convertToJSFile(myPath ); 
if (jsFile.exists()) {
   // the file should exist
}

Thanks Patrick,

I am checking.

Patrick,

It is not Working…

Any Other Help…

It is not working… is not very specific.

I have just used this code:

var myPath = 'C:\\test.xls';
var jsFile = plugins.file.convertToJSFile(myPath);
if (jsFile.exists()) {
	application.output('File exists');
}

and it does work. I have tried with the file existing and without that file.

patrick:
It is not working… is not very specific.

I have just used this code:

var myPath = 'C:\\test.xls';

var jsFile = plugins.file.convertToJSFile(myPath);
if (jsFile.exists()) {
application.output(‘File exists’);
}




and it does work. I have tried with the file existing and without that file.

It is working but, try to put that file under certain derctory?
that mean :-

var myPath = 'C:\\temp\test.xls';

is it working?

It works for any path. Just change the path I have used to demonstrate the idea…