分析文件路徑、文件名、拓展名
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);
}
}
最後更新:2017-04-02 00:06:49