Solved

Open Files in a folder

Posted on 2003-12-12
1
510 Views
Last Modified: 2012-05-04
How can I just have a program consecutively open each file in a specified folder in order? I don't want to have to select them (because the puts a limit to around 400 or so). I just need it to take a folder and load each file one after another.
0
Comment
Question by:derekthornton
1 Comment
 
LVL 7

Accepted Solution

by:
TransBind earned 500 total points
ID: 9928876
This worked for me.  I'm just printing the output but you can replace the Response.Write line with any type of array or ArrayList, etc.

private void Page_Load(object sender, System.EventArgs e)
{
  DirectoryInfo dir = new DirectoryInfo("D:\\EfficiencyLab\\");
      TraverseFolder(dir);              
}

    private void TraverseFolder(DirectoryInfo dir)
    {
      FileInfo[] filesInDir = dir.GetFiles();
      foreach(FileInfo file in filesInDir)
      {
        Response.Write(file.Name + "<br>");        
      }
      DirectoryInfo[] directories = dir.GetDirectories();
      foreach(DirectoryInfo newDir in directories)
      {
        TraverseFolder(newDir);
      }

This is also a recursive function.  I tried it out and it's fast.  Just don't try to access any restricted directories.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Desktop Application 3 54
Firing an ASP.NET event on selection of a JQuery datepicker 4 31
Object Oriented Programming, C#, referencing, scoping. 13 69
C# Gridview 1 48
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question