2013-04-12 2 views
10

내 음악에 모든 라이브러리 위치를 추가하려면 어떻게합니까?탐색기 라이브러리 내의 모든 디렉토리 가져 오기

이 예를 들어

, 나는 도서관에이 디렉토리를 추가했습니다 :

E:\My Music 
E:\Mp3 

나는 시도 :

Environment.GetFolderPath(Environment.SpecialFolder.MyMusic); 

을하지만 반환

C:\Users\MyUser\Music 

+0

두 개의 폴더 만 존재하는 경우 수동으로 디렉토리를 하나씩 추가 할 수 있습니까? –

+1

내 라이브러리 위치에 추가 할 디렉토리가 많아서 하나씩 추가하는 것은 나를위한 옵션이 아닙니다. :) –

+2

당신은 당신을 위해 일을 처리했지만, 어떻게 완료되었는지에 대한 좋은 예가 있습니다. http://www.codeproject.com/Articles/143038/Parsing-Windows-7-Libraries-Without-NET-4-or-the-W –

답변

1

Media Player에 추가 된 모든 라이브러리는 AppData 디렉토리에 있어야합니다.

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\Libraries\Music.library-ms" 

아마도 도움이 될 것입니다.

0

나는이 다른 StackOverflow의 질문에 유사한 posted a full solution with code using Windows API Code Pack 일을했다. 귀하의 경우에는, 당신은 말한다 코드를 찾아 낼 것입니다 :

 ICollection<IKnownFolder> allSpecialFolders = Microsoft.WindowsAPICodePack.Shell.KnownFolders.All; 

을 그리고 당신의 필요에 맞는 하나를 찾으려면 다음 폴더 반복 :

string fpath = ""; 
    // Iterate over each folder and find the one we want 
    foreach (var folder in allSpecialFolders) 
    { 
     if (folder.ParsingName == foldername) 
     { 
      // We now have access to the xml path 
      fpath = folder.Path; 
     } 
    } 

    if (fpath == "") 
     return null; 

    var intFolders = GetLibraryInternalFolders(fpath); 

    return intFolders.Folders.ToList(); 

을 그리고 다음을 반환 GetLibraryInternalFolders() 기능을 사용하여 그 안에 여러 개의 폴더가 있습니다. 어쨌든 다른 질문에서 풀 코드 해결책을 확인하십시오.

관련 문제