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
travishabermanAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sun4sundayConnect With a Mentor Commented:
GetFilename method may help you
http://www.codeproject.com/csharp/dandtutorial.asp

sun4sunday
0
 
sun4sundayCommented:
System.IO.Path.GetFileName(FILE_PATH)

something like this

sun4sunday
0
 
angus_young_acdcCommented:
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
0
All Courses

From novice to tech pro — start learning today.