In my C# program I have to browse directories.
So I use the method
System.IO.Directory.GetFiles(directory)
and it works well when directory is a real directory like "C:\Program File" but when it's a virtual directory (eg: librairie directory), directory value looks like this : "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\Pictures.library-ms" and I don't know how to browse it.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You need to translate the virtual path into a physical one, try:
You might want to read up on DirectoryInfo. If that's no use, give this a try this instead:
I know this is crazy old, but in case someone wants the solution, here is what I have figured out over the past half-day looking into this. There are several solutions out there that can get you the folder names if you give it the path to the Virtual Folder's XML location , but nothing I have seen gets you there from
::{031E4825-....}
. There was a hint in another question's answer to use the WindowsAPICodePack's KnownFoldersBrowser example. So I read through the source code in that and have come up with the following:Here is the DialogBox I was using to get folders, and I have enabled it for AllowNonFileSystemItems, which allows Library folder selections:
I then iterate over
allSpecialFolders
to find this same::{031E4825-...}
which is the ParsingName for the SpecialFolder (yeah, probably a more elegant way). After that, use the XML reading from other solutions (I used a CodeProject example that did the same thing) to get the folders in that library folder:Hope this helps someone in future!