Link to home
Start Free TrialLog in
Avatar of travishaberman
travishaberman

asked on

C#... get file name.

Hi Experts,

I have a infoPath file that has a button on it - if you are not familiar with infopath you may still be able to help me.  I just need to retrive the filename of the infopath form using c#.  That is, when the button is pressed I need the code run underneith the button to retrieve the filename of the form.  If you are not familiar with infopath, I you may be able to help me by telling me how one would do this if the button were set up on some other type of file that you are familiar with.

Thanks,

-TH
ASKER CERTIFIED SOLUTION
Avatar of sun4sunday
sun4sunday
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
System.IO.Path.GetFileName(FILE_PATH)

something like this

sun4sunday
Avatar of angus_young_acdc
Get filename with extension
System.IO.Path.GetFileName([path]);

Get filename without extension
System.IO.Path.GetFileNameWithoutExtension([path]);

For example if you wanted to get the name of the HTML in a webBrowser object the path would be:
webBrowser1.URL.AbsolutePath