• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

return directories and sub directories

i wanna create a function that returns all directories and sub directories in a given path could i find help here
0
hema_jone_mickey
Asked:
hema_jone_mickey
  • 3
  • 2
1 Solution
 
psdavisCommented:
Check out the File and Path classes to start with.  Let me see what else is available.

0
 
psdavisCommented:
Ah, here ya go.  The Directory class.

         string[] strFiles = Directory.GetFiles( @"C:\" ).
0
 
psdavisCommented:

public void ListDirectory( string strPathName )
{
   Console.Output( "Directory: " + strPathName );

   string[] strDirectories = Directory.GetDirectories( strPathName );

   foreach( string strDirectory in strDirectories )
   {
      ListDirectory( strDirectory );
   }
}

0
 
hema_jone_mickeyAuthor Commented:
thanks for all .with just small amount of thinking    thnaks Psdavis)
i figured the solution
public ArrayList directories=new ArrayList();
void getAlldir(string dir)
            {
                  string [] dirs =Directory.GetDirectories(dir);
                  if(dirs.Length!=0)
                  {
                        for(int i=0;i<dirs.Length;i++)
                              directories.Add(dirs[i]);
                        
                        for(int j=0;j<dirs.Length;j++)
                              getAlldir(dirs[j]);
                  }
            }
0
 
hema_jone_mickeyAuthor Commented:
but the proplem i wanna add this files in a zip file
i'm using ICSharp.Nzip.zip
but it doesn't add all of them does any one knows how to accomplish that
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now