2
Answers

How to retrieve the filename from openfiledialog

Ask a question
nicia

nicia

19y
2.3k
1

hi, i like to ask if there anyway that i can get the filename from openfiledialog. I just want the filename and not the all pathway. 
Below is the coding i have done.

openFileDialog.showDialog();
textfile = openFileDialog.FileName;

but this will give me the pathway of the file
e.g. (C:\Documents and Settings\Annicia\Desktop\annicia\SQL Server.exe) but i only want the filename (SQL Server.exe). 
If there anyway i can do it as i am quite new to c# can guide me along, thank. 


Answers (2)