Click here to Skip to main content
15,891,763 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Table named "Note" Pin
Dave Kreskowiak15-Feb-07 13:12
mveDave Kreskowiak15-Feb-07 13:12 
Questionediting attachment before sending it Pin
7prince15-Feb-07 5:35
7prince15-Feb-07 5:35 
Questionget all directories in Computer Pin
turtle101015-Feb-07 4:24
turtle101015-Feb-07 4:24 
AnswerRe: get all directories in Computer Pin
Marcus J. Smith15-Feb-07 4:29
professionalMarcus J. Smith15-Feb-07 4:29 
AnswerRe: get all directories in Computer Pin
Colin Angus Mackay15-Feb-07 4:34
Colin Angus Mackay15-Feb-07 4:34 
GeneralRe: get all directories in Computer Pin
turtle101015-Feb-07 6:53
turtle101015-Feb-07 6:53 
GeneralRe: get all directories in Computer Pin
Dave Kreskowiak15-Feb-07 13:08
mveDave Kreskowiak15-Feb-07 13:08 
GeneralRe: get all directories in Computer Pin
Colin Angus Mackay15-Feb-07 13:43
Colin Angus Mackay15-Feb-07 13:43 
Maybe something like this.

You call the method and pass in a DirectoryInfo object that is created with the root path (e.g. C:\), or any path, and it will return all the subdirectories from there. The catch it to handle the exception where you are not permitted into a subdirectory.
public static List<DirectoryInfo> GetSubdirectories(DirectoryInfo directory)
{
    // Set up the result of the method.
    List<DirectoryInfo> result = new List<DirectoryInfo>();

    // Attempt to get a list of immediate child directories from the directory
    // that was passed in to the method.
    DirectoryInfo[] childDirectories;
    try
    {
        childDirectories = directory.GetDirectories();
    }
    catch (UnauthorizedAccessException uae)
    {
        // If the permissions do not authorise access to the contents of the
        // directory then return an empty list.
        Debug.Print(uae.Message);
        return result;
    }
    
    // Loop over all the child directories to get their contents.
    foreach (DirectoryInfo childDirectory in childDirectories)
    {
        // Add the child directory to the result list
        result.Add(childDirectory);
        
        // Get any children of the current child directory
        List<DirectoryInfo> grandchildDirectories = GetSubdirectories(childDirectory);

        // Add the child's children (the grandchildren) to the result list.
        result.AddRange(grandchildDirectories);
    }

    // return the full list of all subdirectories of the one passed in.
    return result;
}



AnswerRe: get all directories in Computer Pin
ednrgc15-Feb-07 4:51
ednrgc15-Feb-07 4:51 
Questioncomponents file in vb.net Pin
amaneet15-Feb-07 4:12
amaneet15-Feb-07 4:12 
Questionserver error Pin
Sarfaraj Ahmed15-Feb-07 3:37
Sarfaraj Ahmed15-Feb-07 3:37 
AnswerRe: server error Pin
Dave Kreskowiak15-Feb-07 13:03
mveDave Kreskowiak15-Feb-07 13:03 
Questionhai Pin
Ishwarya M15-Feb-07 2:31
Ishwarya M15-Feb-07 2:31 
AnswerRe: hai Pin
Marcus J. Smith15-Feb-07 3:02
professionalMarcus J. Smith15-Feb-07 3:02 
GeneralRe: hai Pin
Ishwarya M15-Feb-07 4:12
Ishwarya M15-Feb-07 4:12 
AnswerRe: hai Pin
Colin Angus Mackay15-Feb-07 4:19
Colin Angus Mackay15-Feb-07 4:19 
GeneralRe: hai Pin
Marcus J. Smith15-Feb-07 4:25
professionalMarcus J. Smith15-Feb-07 4:25 
GeneralRe: hai Pin
Colin Angus Mackay15-Feb-07 4:31
Colin Angus Mackay15-Feb-07 4:31 
AnswerRe: hai Pin
Marcus J. Smith15-Feb-07 4:46
professionalMarcus J. Smith15-Feb-07 4:46 
QuestionString length problem Pin
penguin500015-Feb-07 2:29
penguin500015-Feb-07 2:29 
AnswerRe: String length problem Pin
Tamimi - Code15-Feb-07 3:49
Tamimi - Code15-Feb-07 3:49 
GeneralRe: String length problem Pin
penguin500015-Feb-07 23:25
penguin500015-Feb-07 23:25 
Questionsecond form Pin
KOKEMO15-Feb-07 1:47
KOKEMO15-Feb-07 1:47 
AnswerRe: second form Pin
Marcus J. Smith15-Feb-07 2:13
professionalMarcus J. Smith15-Feb-07 2:13 
AnswerRe: second form Pin
jim_taylor16-Feb-07 10:21
jim_taylor16-Feb-07 10:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.