public static String[] stringToPath(String s) {List<String> parts = new ArrayList<>();int length = s.length();if (length == 0) {return new String[0];}char[] buffer = new char[length];int upto = 0;boolean lastEscape = false;for(int i=0;i<length;i++) {char ch = s.charAt(i);if (lastEscape) {buffer[upto++] = ch;lastEscape = false;} else if (ch == ESCAPE_CHAR) {lastEscape = true;} else if (ch == DELIM_CHAR) {parts.add(new String(buffer, 0, upto));upto = 0;} else {buffer[upto++] = ch;}}parts.add(new String(buffer, 0, upto));assert !lastEscape;return parts.toArray(new String[parts.size()]);}

public static string[] StringToPath(string s){IList<string> parts = new List<string>();int length = s.Length;if (length == 0){return new string[0];}char[] buffer = new char[length];int upto = 0;bool lastEscape = false;for (int i = 0; i < length; i++){char ch = s[i];if (lastEscape){buffer[upto++] = ch;lastEscape = false;}else if (ch == ESCAPE_CHAR){lastEscape = true;}else if (ch == DELIM_CHAR){parts.Add(new string(buffer, 0, upto));upto = 0;}else{buffer[upto++] = ch;}}parts.Add(new string(buffer, 0, upto));Debug.Assert(!lastEscape);return parts.ToArray();}
