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

C#

 
AnswerRe: SQL connectivity issue in My own Windows Serive Pin
SeMartens27-Jan-10 0:53
SeMartens27-Jan-10 0:53 
AnswerRe: SQL connectivity issue in My own Windows Serive Pin
Covean27-Jan-10 1:01
Covean27-Jan-10 1:01 
AnswerRe: SQL connectivity issue in My own Windows Serive Pin
PIEBALDconsult27-Jan-10 5:32
mvePIEBALDconsult27-Jan-10 5:32 
GeneralRe: SQL connectivity issue in My own Windows Serive Pin
WinCrs27-Jan-10 18:19
WinCrs27-Jan-10 18:19 
Questionrecursive folder compare Pin
vantoora26-Jan-10 23:39
vantoora26-Jan-10 23:39 
AnswerRe: recursive folder compare Pin
SeMartens26-Jan-10 23:55
SeMartens26-Jan-10 23:55 
GeneralRe: recursive folder compare Pin
vantoora27-Jan-10 19:00
vantoora27-Jan-10 19:00 
GeneralRe: recursive folder compare Pin
vantoora29-Jan-10 2:16
vantoora29-Jan-10 2:16 
So finally here is my final code which is what i expect to have (no lack of memory usage nor cpu usage) :

static void Main(string[] args) {
  /// args[0] : source server
  /// args[1] : destination server
  /// 
  CombinePaths(args[0], args[1]);
}

private static void CombinePaths(string S, string D) {
  int indexRoot = S.Length + 1;
  var stack = new Stack<string>();
  stack.Push(S);
  while (stack.Count > 0) {
     string dir = stack.Pop();
     try {
        foreach (string sd in Directory.GetDirectories(dir)) {
           stack.Push(sd);
           // Console.WriteLine(dn.ToString());
           string foldername = sd.Substring(indexRoot);
           string combination = Path.Combine(D, foldername);
           if (!Directory.Exists(combination))
           {
              // Console.WriteLine(combination);
              Console.WriteLine(sd);
           }
        }
      }
      catch (UnauthorizedAccessException e)
      {
        Log.Add(e.Message);
      }
  }
}


The principle is this : the program iterate all directories inside the root folder, then parse the length to the subdirectories that it combine with the destination server, to finally check if the folder just listed from the source server exist in the destination server. (I think it some kind of "dir /s" in DOS Command). It is what i expect to have during 9 days but i still need help to optimize my apps.
As I've just count now, some of my root folder contains 2,000,000 - 3,000,000 folders inside. So I do not want to iterate all of this but i need to stop at level ten (10) or twenty (20), means i need to specify a deep level of iteration but i don't know how to make it by using this stack<> techniques.

Any suggestions are welcome. Thanks for all!
QuestionRendering issue C# Pin
Paul Harsent26-Jan-10 23:28
Paul Harsent26-Jan-10 23:28 
AnswerRe: Rendering issue C# Pin
tolw27-Jan-10 19:30
tolw27-Jan-10 19:30 
QuestionExplicit casting with Type variable Pin
Kaikus26-Jan-10 23:21
Kaikus26-Jan-10 23:21 
AnswerRe: Explicit casting with Type variable Pin
OriginalGriff26-Jan-10 23:45
mveOriginalGriff26-Jan-10 23:45 
GeneralRe: Explicit casting with Type variable Pin
Kaikus27-Jan-10 0:48
Kaikus27-Jan-10 0:48 
GeneralRe: Explicit casting with Type variable Pin
OriginalGriff27-Jan-10 1:16
mveOriginalGriff27-Jan-10 1:16 
GeneralRe: Explicit casting with Type variable Pin
Kaikus27-Jan-10 22:21
Kaikus27-Jan-10 22:21 
GeneralRe: Explicit casting with Type variable Pin
Gideon Engelberth27-Jan-10 4:40
Gideon Engelberth27-Jan-10 4:40 
GeneralRe: Explicit casting with Type variable Pin
Kaikus27-Jan-10 22:26
Kaikus27-Jan-10 22:26 
GeneralRe: Explicit casting with Type variable Pin
Gideon Engelberth28-Jan-10 2:47
Gideon Engelberth28-Jan-10 2:47 
AnswerRe: Explicit casting with Type variable Pin
PIEBALDconsult27-Jan-10 5:33
mvePIEBALDconsult27-Jan-10 5:33 
QuestionExecute smtpclient authenticate method from reflection? Pin
ankit_verma26-Jan-10 23:14
ankit_verma26-Jan-10 23:14 
AnswerRe: Execute smtpclient authenticate method from reflection? Pin
SeMartens26-Jan-10 23:45
SeMartens26-Jan-10 23:45 
GeneralRe: Execute smtpclient authenticate method from reflection? Pin
ankit_verma26-Jan-10 23:48
ankit_verma26-Jan-10 23:48 
GeneralRe: Execute smtpclient authenticate method from reflection? Pin
SeMartens26-Jan-10 23:53
SeMartens26-Jan-10 23:53 
GeneralRe: Execute smtpclient authenticate method from reflection? Pin
ankit_verma27-Jan-10 0:10
ankit_verma27-Jan-10 0:10 
GeneralRe: Execute smtpclient authenticate method from reflection? Pin
SeMartens27-Jan-10 0:17
SeMartens27-Jan-10 0:17 

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.