The only way I know (using C#) is to find the last slash and then get all characters after that.
[CS]
string strFile = OpenDialog1.FileName;
strFile = strFile.Substring(strFile.LastIndexOf("\"));
[/CS]
Using LastIndexOf("\") we find the last place the slash is used,
this denotes the last directory. Everything after that is the filename
and extension. So we use substring to obtain everything after that point.
You could also set the RestoreDirectory to false and then use the current directory and parse this out of your FileName, thus giving you the file name on its own.
It is a bit silly that there isint a property that has the name on its own.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.