Click here to Skip to main content
15,889,876 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionForm appears hidden behind google maps in expanded mode. Pin
BibiStars6-Sep-19 4:11
BibiStars6-Sep-19 4:11 
AnswerRe: Form appears hidden behind google maps in expanded mode. Pin
dan!sh 6-Sep-19 4:44
professional dan!sh 6-Sep-19 4:44 
GeneralRe: Form appears hidden behind google maps in expanded mode. Pin
BibiStars7-Sep-19 3:28
BibiStars7-Sep-19 3:28 
GeneralRe: Form appears hidden behind google maps in expanded mode. Pin
Ryan Elias22-Oct-19 2:35
Ryan Elias22-Oct-19 2:35 
Questionsqlconnection Pin
Nithya MCA25-Aug-19 5:10
Nithya 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
Harley 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:
C#
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
Harley 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
Harley Burton14-Aug-19 4:52 
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
Member 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
Member 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
NSE India5-Aug-19 22:08 
AnswerRe: How to crystal report Short by Month.Year Pin
Richard Andrew x646-Aug-19 12:23
professionalRichard Andrew x646-Aug-19 12:23 
AnswerRe: How to crystal report Short by Month.Year Pin
Richard Deeming7-Aug-19 9:38
mveRichard Deeming7-Aug-19 9:38 

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.