Copy link to clipboard
Copied
I'm having a problem with getFiles() - changing it from a user supplied path with selectDialog to a hard coded path. I know there are bug issues with early versions of CS and getFiles, but I can't see where I'm going wrong with:
// just get files
var sourceFolder = "C:\\temp\\json";
if (sourceFolder != null)
{
var fileList = sourceFolder.getFiles();
}
Thank you.
Yes you can use either forward or back slashes. That wasn't the reason for your problems with getFiles(). The problem is you were trying to use a folder method on a string object.
// just get files
var sourceFolder = "C:\\temp\\json";// this is a string object
if (sourceFolder != null)// it will never be null because it was just defined on th line above. Did you mean sourceFolder.exists?
{
//var fileList = sourceFolder.getFiles();// strings do not have a getFiles method.
var fileList = Folder(sou
Copy link to clipboard
Copied
Try
var sourceFolder = Folder("C:
temp
json");
Copy link to clipboard
Copied
There are two ways to list a path, one as X shows, the other is using "/" and no colon. It looks like your main issue is the double backslashes,
Copy link to clipboard
Copied
var sourceFolder = Folder("C:
temp
json");
That just gets me: Error 4: Unterminated string constant.
ha ha! I've just seen what's gone on. The slashes have been turned into new lines by the web pixies. All appease the web pixies! Feed them sour milk, diet donuts and slashes! Ahem....
It should have read
var sourceFolder = Folder("C:/temp/json");
also works with back slashes
var sourceFolder = Folder("C:\\temp\\json"); // use back slashes
Copy link to clipboard
Copied
Yes you can use either forward or back slashes. That wasn't the reason for your problems with getFiles(). The problem is you were trying to use a folder method on a string object.
// just get files
var sourceFolder = "C:\\temp\\json";// this is a string object
if (sourceFolder != null)// it will never be null because it was just defined on th line above. Did you mean sourceFolder.exists?
{
//var fileList = sourceFolder.getFiles();// strings do not have a getFiles method.
var fileList = Folder(sourceFolder).getFiles();
}