• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

Get the files name based on their file extenstion

Example user select a location in their directory, I want to get all files name based on a file type, like .xml???  how to I get all the file name based on this extenstion??? I using Visual stuido 2005 coding in C++.net
0
xiaoxin85
Asked:
xiaoxin85
  • 3
  • 3
  • 2
1 Solution
 
Jai STech ArchCommented:
use a folder browse dialog and loop thru the files in that directory...
or better to FILTER the object with the file type extension as you search in normal windows...
0
 
xiaoxin85Author Commented:
I already used a folder browser dialog but I do not know how to get the extension part, can provide coding will b great.
0
 
surajgupthaCommented:
Use Windows.Forms.OpenFileDialog and set the
OpenFileDialog .Filter = "XML Files(*.xma)|*.xml";
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
surajgupthaCommented:
Check this out
FolderBrowserDialog dia = new FolderBrowserDialog();
dia.ShowDialog();
System.IO.Directory.GetFiles(dia.SelectedPath, "*.xml");
0
 
xiaoxin85Author Commented:
     folderBrowserDialog1->RootFolder = Environment::SpecialFolder::MyComputer;
      System::Windows::Forms::DialogResult result = folderBrowserDialog1->ShowDialog();
      if (System::Windows::Forms::DialogResult::OK == result)
      SourceTOCTxt->Text = folderBrowserDialog1->SelectedPath;
This is what I had done, how to I add on the code to get the file extenstion???
0
 
surajgupthaCommented:
File[] xmlFiles = System.IO.Directory.GetFiles(folderBrowserDialog1->SelectedPath, "*.xml");
0
 
Jai STech ArchCommented:
this will give you the extension
folderBrowserDialog1->SelectedPath->ToString()->Substring(folderBrowserDialog1->SelectedPath->Length-4,4)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now