Forum Discussion

tmahender12's avatar
tmahender12
Frequent Contributor
8 years ago

access all files in a folder

Hi,

 

I have 10 xls files which i need to access one by one, and upload in my application, can u pls let me know how i can loop to access them

 

 

thanks

Mahender

 

3 Replies

  •   var files = aqFileSystem.FindFiles("C:\\Excel Files", "*.xlsx");
      while (files.HasNext()) {
        file = files.Next();
        //Upload file 
      }
    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Exactly, altemann.  The only thing I'd add is that, for the upload, you most likely will need the path for the file.  The "file" variable indicated in the altemann's sample has a property "Path" that will give you the full file path.  

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    From your question, I'm assuming you don't need to actually read the contents of the file but simply get the list of files and then access them for upload.

     

    In that case, I'd use the aqFileSystem.FindFiles method to return a list of files in a folder that match a particular search criteria.  You can then iterate through that list of files and obtain the full path for each file which you can then use for upload. There's an example on how to use the method in the article I linked.  Hope this helps!