Skip to main content
Participant
January 29, 2008
Question

Using File.list()

  • January 29, 2008
  • 1 reply
  • 294 views
Hi,
Im using FMS 3 on the server side when onConnect occures i need an array of all file that is the directory root/streams/myApp
how do use the File.list() ? do i need to create a new file just for getting the list of files of the directory? and how do i get to do that on the directory i want ? is it like this:
File.list(function(name){ return name.indexOf("streams/myApp/")!=-1);
i so the example in the doc files :
var a = x.currentDir.list(function(name){return name.length==3;});
does x is a File object? and where the currentDir came from its not a File property?

Please help ...
    This topic has been closed for replies.

    1 reply

    January 29, 2008
    In SSAS, File objects represent both files and directories.

    The "x" in the examples just means "arbitrary thing that has a member of whatever type we're talking about." In this case, "x" is something that has a member called "currentDir" that's a File object (presumably representing the current directory).

    I'm pretty sure you can create an equivalent like this:

    currentDir = File(".");

    Also, your search isn't going to work the way you expected. The find function doesn't search all subfolders recursively, and the name parameter only gets the filename (the last component of the path), not the entire pathname. You're going to want to open streams/myApp as a File, then just list everything in it.
    inwonderAuthor
    Participant
    January 30, 2008
    Hi,
    first thank, second i'm not sure that File(".") gives the current directory because when i tried it and then trace x.name i got nothing also it faild open it. but how do i move to the directory i want the best was if i could create this file object on the directory where all the files i want are. but how do i do that . i tried x.position = "/streams/myapp" but i don't think that what it ment for. so any idea?