I have been trying to look for a file in all the possible directories inside "My Documents", but it's throwing the "System.UnauthorizedAccessException" exception because of the "My music" folder.
I thought maybe listing all the folders within "My documents", then getting the path of "My music" and excluding it from being searched would solve the problem, but it failed...
So now I have no idea how to find a specific ".ini" file within all the folders inside "My documents" without getting that exception, can anyone help me please? :)
The code I used:
DirectoryInfo dir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
foreach(FileInfo file in dir.GetFiles("*.ini", SearchOption.AllDirectories))
{
listBox1.Items.Add(file.Name);
}