Changing Directory Paths in C#
<p>Beginner here.</p>

<p>I have a directory structure that has a folder with a random number in the path.</p>

<p>i.e. <code>c:\folderA\subfolder\dump1\history\var</code>, <code>c:\folderA\subfolder\dump22\history\var</code></p>

<p>I want the program to read each directory path dynamically. So I split the paths into "partial path" + "fix path". See code.</p>

<p>This is done because \dump* is the unknown and I don't want to hard code it. </p>

<p>The snippet of code below works and is successful but I want to manipulate a portion of the string from the result.</p>

<p>And there lies my problem, I don't know how to change partition string <code>c:\</code> to something else. Perhaps a new partition <code>d:\</code> or a UNC path <code>\\someserver\fileshare</code></p>

<p>If successfull, it would look like this:</p>

<pre><code>D:\folderA\subfolder\dump22\history\var
</code></pre>

<p>Or</p>

<pre><code>\\someserver\fileshare\folderA\subfolder\dump22\history\var
</code></pre>

<p>This is done so I can write additional code to move contents from \var to another directory etc. </p>

<pre><code>{
    static void Main()
    {

        // Grab directory root

        string[] array1 = Directory.GetDirectories(@"c:\folderA\subfolder\");


        // Display all directory paths
        Console.WriteLine("--- Paths---");
        foreach (string name in array1)
        {
             // Add Partial Path + Fix Path

            String CombinePath = (name + "\\history\\var");
            Console.WriteLine(CombinePath);

            //Results
    //c:\folderA\subfolder\dump1\history\var
            //c:\folderA\subfolder\dump22\history\var

            {

                //pause
                Console.ReadLine();
            }
        }
    }
  }
}
</code></pre>
