How to get a file name from a FileDialog?
-
I know that there is a possibility to get the name of the file after choosing it in the FileDialog, like this:
String str=fileDialog1.fileName()
The String(str) includes the full address of the file. for example: str="c:\windows\system\abc.txt" but i want only the file name(abc.txt).:confused: how can i receive only the file name and not the full address? thank you G.
-
I know that there is a possibility to get the name of the file after choosing it in the FileDialog, like this:
String str=fileDialog1.fileName()
The String(str) includes the full address of the file. for example: str="c:\windows\system\abc.txt" but i want only the file name(abc.txt).:confused: how can i receive only the file name and not the full address? thank you G.
-
I know that there is a possibility to get the name of the file after choosing it in the FileDialog, like this:
String str=fileDialog1.fileName()
The String(str) includes the full address of the file. for example: str="c:\windows\system\abc.txt" but i want only the file name(abc.txt).:confused: how can i receive only the file name and not the full address? thank you G.
Try Path.GetFileName[^] passing the full path you get from the file dialog. Also see other static methods in the Path[^] class in case you are interested.
Luis Alonso Ramos Intelectix Chihuahua, Mexico My Blog!
-
I know that there is a possibility to get the name of the file after choosing it in the FileDialog, like this:
String str=fileDialog1.fileName()
The String(str) includes the full address of the file. for example: str="c:\windows\system\abc.txt" but i want only the file name(abc.txt).:confused: how can i receive only the file name and not the full address? thank you G.
hi, you can also use 'FileInfo' class to get some information of your file in the given path.