以将文件夹与文件名分开为例:
OpenFileDialog opendig1 = new OpenFileDialog();
opendig1.CheckFileExists = true;
opendig1.Title = "加载shape数据";
opendig1.Filter = "shape文件|*.shp";
opendig1.ShowDialog();//获取文件路径
string pfullpath = opendig1.FileName;
int pindex = pfullpath.LastIndexOf("\\");//字符串操作函数,找到某一字符位置
string pfilepath = pfullpath.Substring(0, pindex);//文件路径
string pfilename = pfullpath.Substring(pindex + 1);//文件名称