Solved

Open Files in a folder

Posted on 2003-12-12
1
509 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 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