Click here to Skip to main content
15,882,278 members
Home / Discussions / C#
   

C#

 
GeneralRe: Neither validators nor Validationsummery is working Pin
Keith Barrow29-Sep-14 22:37
professionalKeith Barrow29-Sep-14 22:37 
QuestionHo to assign a numbering system to the file system hierarchy Pin
Rick450d25-Sep-14 12:41
Rick450d25-Sep-14 12:41 
JokeRe: Ho to assign a numbering system to the file system hierarchy Pin
PIEBALDconsult25-Sep-14 14:02
mvePIEBALDconsult25-Sep-14 14:02 
GeneralRe: Ho to assign a numbering system to the file system hierarchy Pin
SledgeHammer0125-Sep-14 15:06
SledgeHammer0125-Sep-14 15:06 
AnswerRe: Ho to assign a numbering system to the file system hierarchy PinPopular
Freak3025-Sep-14 22:00
Freak3025-Sep-14 22:00 
SuggestionRe: Ho to assign a numbering system to the file system hierarchy Pin
Richard Deeming26-Sep-14 1:14
mveRichard Deeming26-Sep-14 1:14 
GeneralRe: Ho to assign a numbering system to the file system hierarchy Pin
BillWoodruff26-Sep-14 1:22
professionalBillWoodruff26-Sep-14 1:22 
AnswerRe: Ho to assign a numbering system to the file system hierarchy Pin
BillWoodruff26-Sep-14 1:21
professionalBillWoodruff26-Sep-14 1:21 
I worked on this this morning (GMT +7); when I came back home later I saw that Freak30 had posted a good answer, which I am up-voting.

I'll go ahead and post this since it's slightly different from Freak30's useful code:
C#
private string[] SubDirs;
//
private void GetSubDirs(string currentDirectory, int counter, string currentDirectoryName)
{
    DirectoryInfo di = new DirectoryInfo(item);

    // does the directory exist ?
    if (di.Exists)
    {
        // can we access the directory ?
        if (di.Attributes.HasFlag(FileAttributes.Hidden)) return;

        // avoid other unknown errors in parsing
        try
        {
            //Get next list of folders in the folder hierarchy
            SubDirs = Directory.GetDirectories(item, "*.*", SearchOption.TopDirectoryOnly);

            foreach(string subDir in SubDirs)
            {
                //Increment count of folders within the current folder list
                counter++;
                string iName = sName + "." + counter.ToString();
                Console.WriteLine("{0} Processed Sub-Folder {1}", iName, subDir);
                GetSubDirs(subDir, 0, iName);
            }
        }
        catch (Exception)
        {
            // consider throwing an error ?
            return;
        }
    }
    else
    {
        // consider throwing an error ?
        return;
    }
}
Note this version takes three parameters for the recursive directory-walk method: the current directory to parse's filepath, an integer for the internal counter which is always passed with the value #0, and the current directory's name.
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant

QuestionHow to extract VBA code from Excel in Visual Studio and read it as text with c#? Pin
Member 1110881725-Sep-14 0:01
Member 1110881725-Sep-14 0:01 
AnswerRe: How to extract VBA code from Excel in Visual Studio and read it as text with c#? Pin
Eddy Vluggen25-Sep-14 2:19
professionalEddy Vluggen25-Sep-14 2:19 
AnswerRe: How to extract VBA code from Excel in Visual Studio and read it as text with c#? Pin
Chris Quinn25-Sep-14 4:41
Chris Quinn25-Sep-14 4:41 
QuestionRecevoir des mails Pin
Member 1110858924-Sep-14 23:51
Member 1110858924-Sep-14 23:51 
SuggestionRe: Recevoir des mails Pin
George Jonsson25-Sep-14 0:07
professionalGeorge Jonsson25-Sep-14 0:07 
GeneralRe: Recevoir des mails Pin
Member 1110858925-Sep-14 0:34
Member 1110858925-Sep-14 0:34 
GeneralRe: Recevoir des mails Pin
Richard MacCutchan25-Sep-14 0:45
mveRichard MacCutchan25-Sep-14 0:45 
AnswerRe: Recevoir des mails Pin
Wayne Gaylard25-Sep-14 0:46
professionalWayne Gaylard25-Sep-14 0:46 
SuggestionRe: Recevoir des mails Pin
Richard Deeming25-Sep-14 2:32
mveRichard Deeming25-Sep-14 2:32 
GeneralRe: Recevoir des mails Pin
Wayne Gaylard25-Sep-14 2:36
professionalWayne Gaylard25-Sep-14 2:36 
AnswerRe: Recevoir des mails Pin
George Jonsson25-Sep-14 0:43
professionalGeorge Jonsson25-Sep-14 0:43 
QuestionC# System.Timers.Timer Elapsed event issue Pin
Gangawane24-Sep-14 23:45
Gangawane24-Sep-14 23:45 
AnswerRe: C# System.Timers.Timer Elapsed event issue Pin
BillWoodruff25-Sep-14 0:00
professionalBillWoodruff25-Sep-14 0:00 
SuggestionRe: C# System.Timers.Timer Elapsed event issue Pin
George Jonsson25-Sep-14 0:32
professionalGeorge Jonsson25-Sep-14 0:32 
AnswerRe: C# System.Timers.Timer Elapsed event issue Pin
Dave Kreskowiak25-Sep-14 1:46
mveDave Kreskowiak25-Sep-14 1:46 
AnswerRe: C# System.Timers.Timer Elapsed event issue Pin
Ravi Bhavnani25-Sep-14 9:00
professionalRavi Bhavnani25-Sep-14 9:00 
QuestionHow many way dependency injection can be implemented in c# Pin
Tridip Bhattacharjee24-Sep-14 21:30
professionalTridip Bhattacharjee24-Sep-14 21:30 

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.