private void btnFile_Click(object sender, EventArgs e)
{
if (odlgFile.ShowDialog() == DialogResult.OK)
{
//
//获取文件全路径
//
string strRoot = odlgFile.FileName;
lblPath.Text = strRoot;
//
//获取文件名
//
int iBeginIndex = strRoot.LastIndexOf(@"\") + 1;
int iEndIndex = strRoot.LastIndexOf(".");
lblFileName.Text = strRoot.Substring(iBeginIndex,
iEndIndex - iBeginIndex);
//
//获取文件拓展名
//
iBeginIndex = strRoot.LastIndexOf(".") + 1;
iEndIndex = strRoot.Length;
lblExtendName.Text = strRoot.Substring(iBeginIndex,
iEndIndex - iBeginIndex);
}
}