Hi.
I have two paths: C:\Test\New Folder2
C:\Test\New Folder2\New Folder\a
I would like to gradually make the first path look like the second path. So the first step woould be: C:\Test\New Folder2New Folder
C:\Test\New Folder2\New Folder\a
And the second would be: C:\Test\New Folder2New Folder\a
C:\Test\New Folder2\New Folder\a
Do u have any ideas?
AlanPosted Sep 2, 2008, 12:24 PM
Do you mean like this:
using System;
class Test
{
static void Main()
{
string path1 = @"C:\Test\New Folder2";
string path2 = @"C:\Test\New Folder2\New Folder\a";
int index2 = path2.LastIndexOf("\\");
string fileName = path2.Substring(index2 + 1);
int index1 = path2.LastIndexOf("\\", index2 - 1);
string folderName = path2.Substring(index1 + 1, index2 - index1 - 1);
path1 += "\\" + folderName;
Console.WriteLine(path1);
path1 += "\\" + fileName;
Console.WriteLine(path1);
Console.ReadLine();
}
}