110,535
社区成员
发帖
与我相关
我的任务
分享
string s = @"C:\文件名\文件名\需要替换的文件名\文件.word";
string[] arr = s.Split('\\');
arr[3] = "这里变成--我需要替换的文件名\文件.word";
s = string.Join("\\", arr);
string file =@"C:\文件名\文件名\需要替换的文件名\文件.word";
Console.WriteLine(Path.GetDirectoryName(file)); //C:\文件名\文件名\需要替换的文件名
Console.WriteLine(Path.GetFileName(file)); //文件.word