Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Directory listing

    Hi,

    How to list all the .txt files in a particular drive.
    i.e., If I give the path as C:\ then I should get all the .txt files from all the folders and also sub folders.

    I did something like this, but not able to list all .txt files of sub-folders:
    Code:
    <script type="text/javascript">
    function ListFolders()
    {
      var myFileSysObj = new ActiveXObject("Scripting.FileSystemObject");
      var myFolder = myFileSysObj.GetFolder("C:\\");  
      var myFolderEnum = new Enumerator(myFolder.SubFolders);          
      while(!myFolderEnum.atEnd())
       {
        document.write("<br/><br/><b><u>Following Folder found</u></b><br/>"); 
        folder = myFolderEnum.item();
        document.write(folder+"<br/>"); 
        ListFiles(folder);   
        myFolderEnum.moveNext();  
       } 
    }
    
    function ListFiles(folder)
    {
      var myFileSysObj = new ActiveXObject("Scripting.FileSystemObject");
      var myFolder = myFileSysObj.GetFolder(folder);  
      var myFile = new Enumerator(myFolder.Files);       
      document.write("&nbsp&nbsp&nbsp&nbsp<b><u>Following files were found</u></b><br/>");
      while(!myFile.atEnd())
      {
       file = myFile.item();
       document.write(file+"<br/>");   
       myFile.moveNext();  
      }
      return;
    }
    </script>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    If C:\ isn't part of your webserver's filesystem then yeah you shouldn't be able to get to it. Huge security issue.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •