Click here to Skip to main content
14,602,961 members

.NET (Core and Framework)

 
QuestionForm appears hidden behind google maps in expanded mode. Pin
BibiStars6-Sep-19 4:11
MemberBibiStars6-Sep-19 4:11 
AnswerRe: Form appears hidden behind google maps in expanded mode. Pin
lw@zi 6-Sep-19 4:44
professional lw@zi 6-Sep-19 4:44 
GeneralRe: Form appears hidden behind google maps in expanded mode. Pin
BibiStars7-Sep-19 3:28
MemberBibiStars7-Sep-19 3:28 
GeneralRe: Form appears hidden behind google maps in expanded mode. Pin
Ryan Elias22-Oct-19 2:35
MemberRyan Elias22-Oct-19 2:35 
Questionsqlconnection Pin
Nithya MCA25-Aug-19 5:10
MemberNithya MCA25-Aug-19 5:10 
AnswerRe: sqlconnection Pin
Gerry Schmitz25-Aug-19 11:37
mveGerry Schmitz25-Aug-19 11:37 
QuestionOptimize Directory Parsing and TreeView Population Pin
Harley Burton13-Aug-19 3:16
MemberHarley Burton13-Aug-19 3:16 
AnswerRe: Optimize Directory Parsing and TreeView Population Pin
Richard Deeming13-Aug-19 3:51
mveRichard Deeming13-Aug-19 3:51 
GetFiles and GetDirectories return an array containing all files/directories found. The methods can't return until that array has been populated. You should probably try using EnumerateFiles and EnumerateDirectories instead, and try to remove the ToArray calls.

DirectoryInfo.EnumerateFiles Method (System.IO) | Microsoft Docs[^]
DirectoryInfo.EnumerateDirectories Method (System.IO) | Microsoft Docs[^]

You're also going to want to skip "reparse-point" directories, which can have your code running around in circles.
Reparse Points - Windows applications | Microsoft Docs[^]

There's no need to pass *.* as the search pattern; just omit the parameter.

I'd be inclined to avoid the simple LINQ filters, since you're processing a lot of directories.

Try something like this:
public void ParseProfile(TreeNode parent_node, DirectoryInfo parent_di = null)
{
    if (parent_di == null) parent_di = new DirectoryInfo(parent_node.Name);
    
    try
    {
        foreach (DirectoryInfo dir in parent_di.EnumerateDirectories())
        {
            if ((dir.Attributes & FileAttributes.Hidden) != 0) continue;
            if ((dir.Attributes & FileAttributes.ReparsePoint) != 0) continue;
            TreeNode this_node = parent_node.Nodes.Add(dir.FullName, dir.Name, 0);
            ParseProfile(this_node, dir);
        }
        
        foreach (FileInfo file in parent_di.EnumerateFiles())
        {
            if ((file.Attributes & FileAttributes.Hidden) != 0) continue;
            parent_node.Nodes.Add(file.FullName, file.Name, 1);
        }
    }
    catch (UnauthorizedAccessException e)
    {
        inaccessible.Add(parent_di.FullName);
        Log(e.Message, LOG_LEVEL.access);
    }
    catch (DirectoryNotFoundException e)
    {
        momentaries.Add(parent_di.FullName);
        Log(e.Message, LOG_LEVEL.warning);
    }
    catch (Exception e)
    {
        Log(e.Message, LOG_LEVEL.debug);
        throw;
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


modified 14-Aug-19 4:24am.

GeneralRe: Optimize Directory Parsing and TreeView Population Pin
Harley Burton13-Aug-19 10:41
MemberHarley Burton13-Aug-19 10:41 
GeneralRe: Optimize Directory Parsing and TreeView Population Pin
Richard Deeming13-Aug-19 22:35
mveRichard Deeming13-Aug-19 22:35 
GeneralRe: Optimize Directory Parsing and TreeView Population Pin
Harley Burton14-Aug-19 4:52
MemberHarley Burton14-Aug-19 4:52 
AnswerMessage Closed Pin
20-Aug-19 23:35
professionalColith20-Aug-19 23:35 
AnswerMessage Closed Pin
20-Aug-19 23:41
professionalColith20-Aug-19 23:41 
QuestionWindows Service Installer Problem Pin
Kevin Marois7-Aug-19 6:14
professionalKevin Marois7-Aug-19 6:14 
AnswerRe: Windows Service Installer Problem Pin
Richard Andrew x647-Aug-19 11:47
professionalRichard Andrew x647-Aug-19 11:47 
GeneralRe: Windows Service Installer Problem Pin
Kevin Marois7-Aug-19 12:13
professionalKevin Marois7-Aug-19 12:13 
Question.Net Core web tiff vieawer Pin
Member 145516927-Aug-19 3:55
MemberMember 145516927-Aug-19 3:55 
AnswerRe: .Net Core web tiff vieawer Pin
Richard MacCutchan7-Aug-19 4:14
mveRichard MacCutchan7-Aug-19 4:14 
GeneralRe: .Net Core web tiff vieawer Pin
Member 145516927-Aug-19 4:31
MemberMember 145516927-Aug-19 4:31 
GeneralRe: .Net Core web tiff vieawer Pin
Richard MacCutchan7-Aug-19 5:55
mveRichard MacCutchan7-Aug-19 5:55 
AnswerRe: .Net Core web tiff vieawer Pin
Richard Deeming7-Aug-19 9:44
mveRichard Deeming7-Aug-19 9:44 
QuestionInstalling A Windows Service on Win 10 With Windows Defender Pin
Kevin Marois6-Aug-19 7:23
professionalKevin Marois6-Aug-19 7:23 
AnswerRe: Installing A Windows Service on Win 10 With Windows Defender Pin
Richard Andrew x646-Aug-19 12:13
professionalRichard Andrew x646-Aug-19 12:13 
SuggestionRe: Installing A Windows Service on Win 10 With Windows Defender Pin
Richard Deeming7-Aug-19 9:40
mveRichard Deeming7-Aug-19 9:40 
QuestionHow to crystal report Short by Month.Year Pin
NSE India5-Aug-19 22:08
MemberNSE India5-Aug-19 22:08 

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.