Actionscript to list files in a directory

I'm looking for some sample Actionscript or tutorial that
will give me a list of files in a webhost directory. The webhost
directory is on the same server as the SWF file.

I use a very simple ASP page (asp extensions must be enabled
in iis, are you using iis?)
<%@ LANGUAGE="VBSCRIPT" %>
<% OPTION EXPLICIT %>
<%
Dim myFSO, myFolder, myFile
Set myFSO = Server.CreateObject("Scripting.FileSystemObject")
Set myFolder = myFSO.GetFolder("C:\Inetpub\wwwroot\Servier\"
+ Request("folder"))
Dim myList
myList = "files_list="
For Each myFile in myFolder.Files
myList = myList + myFile.Name + ","
Next
Response.Write myList
%>
Then in ActionScript:
var result_lv:LoadVars = new LoadVars();
var send_lv:LoadVars = new LoadVars();
send_lv.sendAndLoad("ListFolder.asp?folder="+yourFolder,
result_lv, "POST");
result_lv.onLoad = function(success:Boolean) {
if (success) {
for (var n = 0;
n<result_lv.files_list.split(",").length-1; n++) {
something = result_lv.files_list.split(",")[n]; // do what
you need to do with the file name
} else { // display an error message.
mx.controls.Alert.show("Error getting a Folder's content:
"+yourFolder, "");

Similar Messages

  • Listing files of a directory

    I have a block non single record and each record must receive the file name of a directory.
    Does anybody know how can i list files of a directory? Is there any object or package i've got to use?
    Thanks for attemption.

    Is the directory a single directory that your db server has access to? if so you can use a bit of java (in the db), pl/sql and sql to list the files in the given directory in a temporary table, then you can query that table to show in your form.
    Should be able to google a solution by searching on "oracle dirlist" or let me know and I can post what I used here.
    --pat
    PS. how does one get code snipits to format nice when posting here?

  • How to List files in a directory into an Array

    Does anyone know of the best way to load all of the files in a specified directory into an array. (not going into sub directories either).
    I was to be able to do something like this.... (pseudo)
    String directory = "C:\";
    String [] theList;
    do
    get next file name;
    add to theList;
    }while(!End of Directory)
    Done.

        public static void main(String args[]) {
         String directory = "C:\\";
         File dir = new File(directory);
         File [] theList = dir.listFiles();
         for(File file : theList)
             if(!file.isDirectory() && !file.isFile())
              System.out.println(file.getName());
         }This will list every item in the coot of C:\ that is not a file or a directory. Change the if statement to fit your needs.
    ~Tim

  • Failing to list files in remote directory using FTP

    Since I've been using a proxy with FTP transport for pull files from a remote server during several months. Now it started to work just sometimes
    ####<Apr 11, 2011 1:33:50 PM BRT> <Error> <WliSbTransports> <WN7-6J6VJN1> <AdminServer> <pool-9-thread-1> <weblogic> <> <f2be7f1e2af484b9:-47b5d228:12f456185e7:-7ff1-000000000000002c> <1302539630973> <BEA-381602> <Error encountered while polling the resource for the service endpoint ProxyService$Infolease$1_0$ProxyServices$Contract$SendBookingConfirmationPS: com.bea.wli.sb.transports.TransportException: <user:davi_diogo>Unable to list files for directory:.
    com.bea.wli.sb.transports.TransportException: <user:davi_diogo>Unable to list files for directory:.
         at com.bea.wli.sb.transports.ftp.connector.FTPWorkPartitioningAgent.execute(FTPWorkPartitioningAgent.java:218)
         at com.bea.wli.sb.transports.poller.TransportTimerListener.run(TransportTimerListener.java:75)
         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
         at java.util.concurrent.FutureTask.run(FutureTask.java:139)
         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:909)
         at java.lang.Thread.run(Thread.java:619)
    I configured the service account with my own username, and I do make sure that I have the rights over my home\user directory. (I tested with WINSCP and putty).
    I haven't done any modification to make this start happening.
    following my proxy configuration:
    protocol: ftp
    URI: ftp://myhost/
    mask: *.XML
    but no success.
    I said "sometimes" above because it works after ~15 tentatives. Perhaps this could be a issue in my remote server OS.
    Has anyone faced this issue before?
    Thanks in advance,
    Davinod

    Please refer -
    Error encountered while polling the resource for the service endpoint
    Regards,
    Anuj

  • How can i list file in a directory ?

    my goal is to list all JPG and GIF image in current directory (containing also my .class)
    if tried
    try {
    File tmp = new File("PhotoDisplayer.class");
    String[] m_images = tmp.list();
    catch (Exception ex) {
    ex.printStackTrace();
    but i always get m_images to null
    thanks by advance,
    marvinrouge

    First of all, you need your file object to represent a directory and not a file.
    Look up File.listFiles() in the api documentation. It returns an array of File objects.
    Something like:
    String pathSeperator = System.getProperty("path.separator");
    File tmp = new File("path"+pathSeparator+"to"+pathSeparator+"directory");
    File[] dirContent = tmp.listFiles();
    for(int i=0;i<dirContent.length;i++) {
    System.out.println(dirContent.getName());

  • Issue with List Files option in FTP Adapter-

    Hi All,
    I am getting the following error when I am using the list files option inside FTP adapter. The soa Version I am using is 11.1.1.5
    Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'FileListing' failed due to: Error in listing files in the remote directory. Error in listing files in the remote directory. Unable to list file in remote directory. Please make sure that the ftp server settings are correct. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
    I have configured FTP adapter successfully by giving the following details,
    useSftp –
    username –
    password -
    host -
    port –
    authenticationType –
    preferredCipherSuite -
    and it is working perfectly for getfiles option and it is reading files successfully, but it is throwing error when I am using list files option. I tried this option for listing the files that are in remote directory. Any Help would be appreciated.
    Complete fault
    <messages>
    <input>
    <Invoke1_FileListing_InputVariable>
    <part name="Empty">
    <empty/>
    </part>
    </Invoke1_FileListing_InputVariable>
    </input>
    <fault>
    <bpelFault>
    <faultType>0</faultType>
    <bindingFault>
    <part name="summary">
    <summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'FileListing' failed due to: Error in listing files in the remote directory. Error in listing files in the remote directory. Unable to list file in remote directory. Please make sure that the ftp server settings are correct. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary>
    </part>
    <part name="detail">
    <detail>No such file</detail>
    </part>
    <part name="code">
    <code>null</code>
    </part>
    </bindingFault>
    </bpelFault>
    </fault>
    <faultType>
    <message>0</message>
    </faultType>
    </messages>
    May 9, 2013 4:32:00
    Edited by: BK574 on May 9, 2013 2:47 PM

    Is this a bug in SOA suite?
    Following are the properties inside JCA file
    <adapter-config name="List" adapter="FTP Adapter" wsdlLocation="List.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <connection-factory location="eis/ftp/FTPService" UIincludeWildcard="*.*"/>
    <endpoint-interaction portType="FileListing_ptt" operation="FileListing">
    <interaction-spec className="oracle.tip.adapter.ftp.outbound.FTPListInteractionSpec">
    <property name="PhysicalDirectory" value="*.*"/>
    <property name="Recursive" value="true"/>
    <property name="IncludeFiles" value="*.*"/>
    </interaction-spec>
    </endpoint-interaction>
    </adapter-config>
    Edited by: BK574 on May 10, 2013 6:30 AM
    Edited by: BK574 on May 10, 2013 6:31 AM

  • How to list files from .jar file in applet?

    I have created applet and export all files to .jar file.
    I use File.list() method in applet to list files from one directory and that works ok but if I try to do that from web browser it sends exception AccessDenied meaning that File.list() isn't allowed in browser.
    I know what's the problem but I don't know how to solve it.
    What I want is to read from directory list of files.
    Help anyone?

    I will post here my code so that can be seen what I want to do:
    import java.awt.BorderLayout;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URLClassLoader;
    import java.nio.charset.Charset;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.JTextPane;
    public class test extends JApplet {
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JTextPane jTextPane = null;
          * This is the xxx default constructor
         public test() {
              super();
          * This method initializes this
          * @return void
         public void init() {
              this.setSize(449, 317);
              this.setContentPane(getJContentPane());
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(new BorderLayout());
                   jContentPane.add(getJTextPane(), BorderLayout.CENTER);
              return jContentPane;
          * This method initializes jTextPane     
          * @return javax.swing.JTextPane     
         private JTextPane getJTextPane() {
              if (jTextPane == null) {
                   jTextPane = new JTextPane();
              return jTextPane;
         public void start(){
              File fileDir= new File("somedirectory");
              String strFiles[]= fileDir.list();
              String a="";
              for(int i =0;i<strFiles.length;i++){
                   a=a+strFiles;
              this.jTextPane.setText(a);
    Method init() is irelevant, it just adds JTextPane in applet.
    Method start() is relevant, it runs normaly when started from Eclipse but from browser it sends exception AccessDenied.

  • How can I get file list for a given directory?

    Hi,
    How can I get file list for a given directory? Is there a function?
    Thanks.

    Hi friend,
    Try this sample report. It displays all files in a directory.
    While executing give some directory name in input. ex:  C:\
    Mention file type in filter parameter. ex: *.DOC
    REPORT ztests.
    DATA : file_table LIKE TABLE OF sdokpath WITH HEADER LINE .
    DATA : dir_table LIKE TABLE OF sdokpath WITH HEADER LINE .
    PARAMETERS:p_dir(50) TYPE c.
    CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
      EXPORTING
        directory  = p_dir
        filter     = '*.DOC'
      TABLES
        file_table = file_table
        dir_table  = dir_table
      EXCEPTIONS
        cntl_error = 1
        OTHERS     = 2.
    LOOP AT file_table .
      WRITE:/ file_table-pathname.
    ENDLOOP.
    Might be helpful...
    Thanks.....
    Edited by: Guest77 on Feb 11, 2009 5:30 AM

  • List of files in a directory of app server

    Hi,
    I was trying to get the list of all files in a directory using fm "EPS2_GET_DIRECTORY_LISTING". But the date column is empty in the output table. I also tried fm's
    SUBST_GET_FILE_LIST
    EPS_GET_FILE_ATTRIBUTES
    none of the above is giving date.
    Can anyone tell me a fm which gives date along with other attributes?
    Thanks in Advance.
    Satish

    try get something from the transaction AL11 source code: RSWATCH0 form -> fill_file_list
    Regards,
    Vincent

  • Listing files of directory on application server

    hi all,
    I want to download a list of files from the application server.
    I tried the functions:
    - SUBST_GET_FILE_LIST
    - EPS_GET_DIRECTORY_LISTING
    - RZL_READ_DIR_LOCAL
    but the result gives me the name of my file truncated.
    My filename is much longer than the functions give me.
    Is there any other function, or can i bypass this problem in a way.
    Thanks in advance.
    Merijn.

    Hello,
    This is a common problem with this FMs. Even SAP acknowledges this:
    In EPS_GET_DIRECTORY_LISTING you have this:
    data: begin of file,
            dirname(75) type c, " name of directory. (possibly truncated.)
            name(75)    type c, " name of entry. (possibly truncated.)
          end of file.
    The FM uses a Kernel Call 'C_DIR_READ_NEXT' to get the list of the files in the directory. The file name is returned in the field file-name.
    call 'C_DIR_READ_NEXT'
              id 'TYPE'   field file-type
              id 'NAME'   field file-name
              id 'LEN'    field file-len
              id 'OWNER'  field file-owner
              id 'MTIME'  field file-mtime
              id 'MODE'   field file-mode
              id 'ERRNO'  field file-errno
              id 'ERRMSG' field file-errmsg.
    The program RSWATCH0(trxn: AL11) also uses the Kernel call but the structure file is different.
    DIrectory name can be 1024 character long & file name is 260 character long
    data: begin of file,
            dirname(1024)    type c,  " name of directory. (possibly
                                           " truncated.)
            name(260)        type c, " name of entry. (possibly
                                           " truncated.)
            type(10)    type c,            " type of entry.
            len(8)      type p,            " length in bytes.
            owner(8)    type c,            " owner of the entry.
            mtime(6)    type p, " last modification date, seconds since 1970
            mode(9)     type c, " like "rwx-r-x--x": protection mode.
            useable(1)  type c,
            subrc(4)    type c,
            errno(3)    type c,
            errmsg(40)  type c,
            mod_date    type d,
            mod_time(8) type c,            " hh:mm:ss
            seen(1)     type c,
            changed(1)  type c,
          end of file.
    So one workaorund would be to copy EPS_GET_DIRECTORY_LISTING to some custom FM & change the length of the structure file to suit your requirement
    BR,
    Suhas
    PS: Use of Kernel Call is for internal use only & is highly not recommended by SAP.

  • How to list the files in a directory which are recently modififed few mins

    Hi,
    I need command to list the files in a directory which are modified few minutes ago in SunOS. like "find . -cmin 2 -print " which list files that are modified 2 mins ago in Linux platform.
    Thanks in advance.
    sudha85

    The find command that comes with solaris doesnt have the cmin operator. Only mtime whose option is days.
    So install gnu find from sunfreeware which is the same one that comes with linux.

  • List all files in a directory on a server that hosts the applet

    Hei :)
    I have a problem. I want to list all files in a directory on my server. ( http://www.foo.bar/tw )
    The applet is in the root folder ( http://www.foo.bar ).
    So i tried it like this
    File fi = new URL(getCodeBase() + "/all/").getFile();But when I try to list the files, I get a SecurityException.
    Can anyone help me out?
    Peace!
    LoCal

    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=&qt=%2Blist+%2Bfile+%2Bserver

  • Problem with getting a list of files in a directory

    I'm trying to get a list of files in a particular directory. The problem is I'm also getting a listing of all the sub-directories too. Here is my code:
    File directory = new File(dir);
    File[] filelist;
    filelist = directory.listFiles();
    for(int i=0;i<filelist.length;i++)
    System.out.println("FileName = " + filelist.getName());
    What am I doing wrong?
    Thanks
    Brad

    You are not doing anything wrong. You just have to test whether a given file is a subdirectory:
    File directory = new File(dir);
    File[] filelist;
    filelist = directory.listFiles();
    for(int n = 0; n < filelist.length; n++) {
      if (!filelist[n].isDirectory())
        System.out.println("FileName = " + filelist[n].getName());
    }S&oslash;ren Bak

  • List files stored in a Directory Object

    Hi,
    I looked on Google, on Oracle DB docs and here to find a convenient way to list files stored in a DIRECTORY for batch loading in a table with PL/SQL. But no luck, UTL_FILE doesn't seem to have a method for directory listing. I saw examples with some workaround like putting files list in a text file prior to loading. The directory is feeded by other process and network services, so I don't know the filelist that I need to import and, then delete. I dont have access to the server console and it's impossible for me to dump a kind of «dir» result into a text file. I saw other examples using Java, but it looks like I don't have access to Server Side Java too.
    Is there a simple way to do that in PL/SQL only?
    If not, I'll ask to the DBA the necessary rights to compile/run java on the server side...
    The DB target versions for this requirement are 10g and 11g (mainly) on Windows environment.
    Thanks
    Bruno

    brlav35 wrote:
    The XUTL_FINDFILES seems to be the more convenient way. If that works for you, I certainly have no objection. In a lot of environments, though, that package would be problematic.
    1) It must be installed in the SYS schema. That's generally frowned upon and lots of sites would never allow user code to go into the SYS schema. Chris is a bright guy, so I'm sure the risk of it causing harm is minimal (most likely during an install or upgrade), and it will almost certainly never cause you harm, but that would be a political show-stopper at a lot of places.
    2) The package body is wrapped (if there is a version with the package body in clear text, this point is moot). Again, Chris is a well-respected guy, so I have every confidence that the code is not malicious, but asking a DBA to install a wrapped package you downloaded from the internet into the SYS schema on a production database should generate a crud-load of red flags. This is almost certainly just a theoretical danger, but DBAs and audit compliance regulations care a great deal about theoretical dangers. If someone hacked the web site and uploaded their own wrapped bit of code that had a back door, for example, it would be very hard to catch.
    3) Under the covers, the package is querying one of the undocumented X$ views. Oracle is free to change those views over time, which would potentially cause the package to stop working or stop working correctly in some way. If you're developing code for a system that may be around for a number of years, that becomes a concern. It's unlikely that Oracle will change the particular X$ view that is being referenced here over the lifetime of your code base, but it's more than a trivial concern.
    4) The package is determining what directories a user has access to, that's not Oracle enforcing the restriction. Probably not too big a deal, but it is probably safer from a regulatory compliance standpoint to be able to rely on Oracle the database enforcing privileges rather than relying on a delivered package to enforce those privileges. It's the difference between telling Oracle via specific grants which directories the JVM can access vs. writing your own wrapper that enforces those restrictions. In the end, the restrictions are enforced, but in one case you're relying on the developers of the Oracle database and in the other you're relying on external developers.
    Just to re-iterate-- Chris is a brilliant guy, I don't mean this in any way to impugn him or his code. I am totally confident that his code works, that it works well, and that it will continue to work going forward. My concerns are purely on the political/ regulatory side of things, not on the technical side of things. Technically, I am confident that the code is top-notch.
    Justin
    Edited by: Justin Cave on Sep 9, 2009 12:38 PM
    I wrote this before seeing the last few bits of the exchange where you and Chris already talked about the first point.

  • Get the file list of a given directory

    does anyone know how to get the file list of a given directory? I tried "list"/"filelist" but the class not found.
    THanks!

    What made you assume that there exist classes called list or filelist etc.
    Do you read API documentation etc ?
    Anyways, here is a hint java.io.File.listFiles()

Maybe you are looking for