Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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