如文件路径为:
string file = "D:\\test\\WindowsFormsApplication2\\bin\\Debug\\WindowsFormsApplication2.exe"
获取文件所在目录只需要下面这一句话:
string path = file.Substring(0, file.LastIndexOf("\\") + 1);
如文件路径为:
string file = "D:\\test\\WindowsFormsApplication2\\bin\\Debug\\WindowsFormsApplication2.exe"
获取文件所在目录只需要下面这一句话:
string path = file.Substring(0, file.LastIndexOf("\\") + 1);