Search file *.mp3 in computer

111 views Asked by At

how search all *.mp3 and *.wav files in my computer? Visual Studio 2015, Universal Windows App, C++/CX. Thanks

2

There are 2 answers

0
Peter Torr On

The only way to read the user's files (pictures, music, etc.) is to use the StorageFolder APIs. If you assume the music is all inside the Music library, you can simply declare the musicLibrary capability and then use KnownFolders.MusicLibrary as the root folder to search. If you really want to search the entire drive, you need to use FolderPicker and ask the user to select the root directory.

0
Jenia On

If you want to search in cmd (console):

C:\> where *.mp3

Or maybe search in disk D: not using cd command:

C:\> where /R D:\ *.mp3

In C++ code(to show the user):

#include<windows.h>
#include<string>
using namespace std;

//Be carefull: dont use: "C:\Folder\", but: "C:\\Folder\\"; In some cases you can write: "C:/Folder/"
string command = "where /R Disk:\\StartSearchFolder\\ filename"; //filename can be "ex.txt", "*.txt", "ex*";
system(command.c_str());

Can be helpful use ShellExecute()