C# 檔案路徑切割

有時候需要針對全路徑做切割再重新組合新路徑的情況
這個時候就需要用到

string mypath = @"c:\\folder1\folder2\folder3";
string[] directories = mypath.Split(Path.DirectorySeparatorChar);
result
directories[0] = c 
directories[1] = folder1
directories[2] = folder2
directories[3] = folder3
directories.length = 4

ref: https://stackoverflow.com/questions/401304/how-does-one-extract-each-folder-name-from-a-path

發佈留言