, 당신이 Path.Combine가 결정하려면 string.replace와 열린 우리당 클래스의 방법으로 당신이 할 수에게 제공된 문자열
public static string Combine(string path1, string path2)
{
if ((path1 == null) || (path2 == null))
{
throw new ArgumentNullException((path1 == null) ? "path1" : "path2");
}
CheckInvalidPathChars(path1);
CheckInvalidPathChars(path2);
if (path2.Length == 0)
{
return path1;
}
if (path1.Length == 0)
{
return path2;
}
if (IsPathRooted(path2))
{
return path2;
}
char ch = path1[path1.Length - 1];
if (((ch != DirectorySeparatorChar) && (ch != AltDirectorySeparatorChar)) && (ch != VolumeSeparatorChar))
{
return (path1 + DirectorySeparatorChar + path2);
}
return (path1 + path2);
}
에 동일한 슬래시를 변경하지 않습니다 볼 수 있습니다 닷넷 리플렉터를 사용하는 일 당신을 위해 가장 잘 작동합니다.
백 슬래시가 문제입니까? .NET 및 Windows 파일 API는이 중 하나를 허용합니다. –
혼합 슬래시의 문제점은 무엇입니까? 화장대? – JBRWilkinson
@ 존, 그렇습니다 : http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx. 아니면 C#과 .NET의 차이점에 대해 뻔뻔스러워 보려고 했습니까? –