C#中openFileDialog打开的文件如何只要文件名不要路径
使用FileInfo类,用路径初始化FileInfo类实例,调用返回FileName属性即可
示例
using System.IO;
String FileName;
openFileDialog1_FileOK(object sender,EventArgs e)
{
FileInfo myFile=new FileInfo(openFileDialog1.FileName);
FileName= myFile.FileName;//myFile.FileName为所需无路径文件名
}