Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
Questionc# window Application"How to resize the control proportionally at runtime using c# window application " Pin
Pranita Gupta29-Apr-15 0:14
professionalPranita Gupta29-Apr-15 0:14 
AnswerRe: c# window Application"How to resize the control proportionally at runtime using c# window application " Pin
Pete O'Hanlon29-Apr-15 0:18
mvePete O'Hanlon29-Apr-15 0:18 
AnswerRe: c# window Application"How to resize the control proportionally at runtime using c# window application " Pin
Eddy Vluggen29-Apr-15 1:12
professionalEddy Vluggen29-Apr-15 1:12 
GeneralRe: c# window Application"How to resize the control proportionally at runtime using c# window application " Pin
OriginalGriff29-Apr-15 4:59
mveOriginalGriff29-Apr-15 4:59 
QuestionWhy designer save Bad COORDINATES of UserControl's Child (EnableDesign) ? Pin
Emanuele Bonin28-Apr-15 23:39
Emanuele Bonin28-Apr-15 23:39 
AnswerRe: Why designer save Bad COORDINATES of UserControl's Child (EnableDesign) ? Pin
BillWoodruff30-Apr-15 3:37
professionalBillWoodruff30-Apr-15 3:37 
GeneralRe: Why designer save Bad COORDINATES of UserControl's Child (EnableDesign) ? Pin
Emanuele Bonin30-Apr-15 6:08
Emanuele Bonin30-Apr-15 6:08 
QuestionMake a faster search of folders Pin
Member 1140151628-Apr-15 11:34
Member 1140151628-Apr-15 11:34 
Recently with the precious help of some forum users i have developed a search application of folders and subfolders. Here's the code:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace Procura_Desenhos1._1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void txt_procura_TextChanged(object sender, EventArgs e)
        {

        }

        private void btn_procura_Click(object sender, EventArgs e)
        {
            string toFind = txt_procura.Text;
            var root = new DirectoryInfo(@"c:\");

            var matchingDirectories = SafeEnumerateDirectories(root)
                .Where(d => string.Equals(d.Name, toFind, StringComparison.OrdinalIgnoreCase))
            ;

            foreach (DirectoryInfo directory in matchingDirectories)
            {
                Process.Start(new ProcessStartInfo
                {
                    FileName = directory.FullName,
                    UseShellExecute = true,
                    Verb = "open"
                });
            }
        }
        public static IEnumerable<DirectoryInfo> SafeEnumerateDirectories(DirectoryInfo root)
        {
            if (root == null) throw new ArgumentNullException("root");
            if (!root.Exists) return Enumerable.Empty<DirectoryInfo>();
            return SafeEnumerateDirectoriesCore(root);
        }

        private static IEnumerable<DirectoryInfo> SafeEnumerateDirectoriesCore(DirectoryInfo root)
        {
            var searchPaths = new Stack<DirectoryInfo>();
            searchPaths.Push(root);

            while (searchPaths.Count != 0)
            {
                DirectoryInfo currentPath = searchPaths.Pop();
                yield return currentPath;

                DirectoryInfo[] subFolders = null;
                try
                {
                    foreach (var subDirectory in currentPath.EnumerateDirectories())
                    {
                        searchPaths.Push(subDirectory);
                    }
                }
                catch (UnauthorizedAccessException)
                {
                }
            }
        }
    }
}


However the path C: it was only for testing (var root = new DirectoryInfo (@ "C: \");) the goal is that the application search folders on a local server (var root = new DirectoryInfo (@ "\ vgst \ clients \ ");). Inside the folder clients there are hundreds and hundreds of subdirectories with a unique ID that is not repeated, this ID is the reference sale. Already tested and the application works however is very slow in searching ,sometimes takes several minutes to open the folder that we sent to search. Is there any way to accelerate this search?

Thanks again,
AnswerRe: Make a faster search of folders Pin
Mycroft Holmes28-Apr-15 14:05
professionalMycroft Holmes28-Apr-15 14:05 
AnswerRe: Make a faster search of folders Pin
Dave Kreskowiak28-Apr-15 14:16
mveDave Kreskowiak28-Apr-15 14:16 
AnswerRe: Make a faster search of folders Pin
Abhinav S28-Apr-15 17:38
Abhinav S28-Apr-15 17:38 
GeneralRe: Make a faster search of folders Pin
Eddy Vluggen28-Apr-15 23:13
professionalEddy Vluggen28-Apr-15 23:13 
GeneralRe: Make a faster search of folders Pin
Abhinav S28-Apr-15 23:24
Abhinav S28-Apr-15 23:24 
AnswerRe: Make a faster search of folders Pin
Pete O'Hanlon29-Apr-15 1:00
mvePete O'Hanlon29-Apr-15 1:00 
SuggestionRe: Make a faster search of folders Pin
Richard Deeming29-Apr-15 1:40
mveRichard Deeming29-Apr-15 1:40 
AnswerRe: Make a faster search of folders Pin
Richard Deeming29-Apr-15 1:35
mveRichard Deeming29-Apr-15 1:35 
AnswerRe: Make a faster search of folders Pin
V.29-Apr-15 2:50
professionalV.29-Apr-15 2:50 
Questionappend array of byte to other which contains '0' Pin
MrKBA28-Apr-15 6:20
MrKBA28-Apr-15 6:20 
AnswerRe: append array of byte to other which contains '0' Pin
OriginalGriff28-Apr-15 6:27
mveOriginalGriff28-Apr-15 6:27 
Questiongf Pin
Member 1148462428-Apr-15 3:44
Member 1148462428-Apr-15 3:44 
AnswerRe: clear my liste of seaid that i got via this method on the uninstall of the application Pin
Abhinav S28-Apr-15 3:49
Abhinav S28-Apr-15 3:49 
General[REPOST] Pin
Sascha Lefèvre28-Apr-15 4:27
professionalSascha Lefèvre28-Apr-15 4:27 
GeneralMessage Closed Pin
28-Apr-15 4:31
Member 1148462428-Apr-15 4:31 
GeneralRe: [REPOST] Pin
Sascha Lefèvre28-Apr-15 4:37
professionalSascha Lefèvre28-Apr-15 4:37 
QuestionGetting string does not contains a definition for containskey error Pin
Member 1035510728-Apr-15 2:28
professionalMember 1035510728-Apr-15 2:28 

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.