System.IO.Path.GetFullPath (Openfiledialog1.filename); Absolute path
System.IO.Path.GetExtension (Openfiledialog1.filename); File name extension
System.IO.Path.GetFileNameWithoutExtension (openfiledialog1.filename);//file name does not have an extension
System.IO.Path.GetFileName (Openfiledialog1.filename); Get the file
System.IO.Path.GetDirectoryName (Openfiledialog1.filename); Get path The return value of the function above is a string type.
The C # code for the Listener event for the button that selects the local file is attached below:
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Windows.Forms; namespace Browsefile {public partial class Form1:form {public Form1 () {Initialize
Component (); } private void Button1_Click (object sender, EventArgs e) {OpenFileDialog Fdlg = new OpenFile
Dialog (); Fdlg.
Title = "C # Corner Open File Dialog"; Fdlg. InitialDirectory = @ "C:\"; @ is the meaning that cancels the escape character Fdlg. Filter = "All Files (*.*) |*.*|
All Files (*.*) |*.* "; * * * FilterIndex property is used to select which file type, the default setting is 0, and the system takes the Filter property to set the first item *, which is equivalent to setting the FilterIndex property to 1. If you make up 3 file types, when Fil
Terindex =2 refers to the 2nd one. * * Fdlg.
FilterIndex = 2;
* * If the value is false, then the next selection of the file's initial directory is the last time you selected the directory, * is not fixed; If the value is true, the initial directory of each open dialog box does not change with your choice, is fixed * * FDLg.
Restoredirectory = true; if (Fdlg. ShowDialog () = = DialogResult.OK) {TextBox1.Text = System.IO.Path.GetFileNameWithoutExtension ( Fdlg.
FileName);
Refer http://blog.sina.com.cn/s/blog_7511914e0101cbjn.html to}}}}