Solved

Pulling a file extension

Posted on 2009-07-05
3
261 Views
Last Modified: 2012-05-07
In c# what is an easy way to find a file extension.

My current way is kinda messy, and is very easy for the user to mess up.

The exact thing required is for the program to go forward one file, and look at a file of extension *.F*  where the second star is a number 4-10

Any Suggestions?
0
Comment
Question by:cotj73
3 Comments
 
LVL 9

Accepted Solution

by:
Rahul Goel earned 175 total points
Comment Utility
You can use RegEx to achieve the same.
0
 
LVL 1

Assisted Solution

by:vaibhav_dw
vaibhav_dw earned 175 total points
Comment Utility
Hi

Are you trying to extract the extension from the filename as the string or you have the filestream?

If you have just the filename as the string then you can traverse the string backwords till the period(.) and then traverse extactly 3 characters to get the extension. This is simply playing with the string.

Could you please tell exactly what do you have as a file so that I can help you out.

0
 
LVL 7

Assisted Solution

by:Raghu Mutalikdesai
Raghu Mutalikdesai earned 150 total points
Comment Utility
// path is your file path
System.IO.Path.GetExtension(path)
System.IO.Path.GetFileNameWithoutExtension(path)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

16 Experts available now in Live!

Get 1:1 Help Now