说我有
string path1 = "C:\\apples";
string path2 = "C:\apples\blah\meh.jpg";
我怎么能得到:
string diff = "\blah\meh.jpg";
由于
答案 0 :(得分:0)
如果Path实际上包含双斜杠(通常不会发生):
将\\
替换为\
path1
将path1
替换为Empty String
path2
string diff = path2.Replace(path1.Replace(@"\\", @"\"), "");
否则:
string diff = path2.Replace(path1, "");