Solved

C#... get file name.

Posted on 2007-03-20
6
2,555 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:travishaberman
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
sun4sunday earned 500 total points
ID: 18761637
GetFilename method may help you
http://www.codeproject.com/csharp/dandtutorial.asp

sun4sunday
0
 
LVL 9

Expert Comment

by:sun4sunday
ID: 18761648
System.IO.Path.GetFileName(FILE_PATH)

something like this

sun4sunday
0
 
LVL 15

Expert Comment

by:angus_young_acdc
ID: 18762523
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now