Hi,
Under windows 7, in the windows explorer view there is a new feature
called "Libraries" which have virtual links to "Pictures", "documents"
etc.. plus you can add your own virtual link.
These libraries are virtual paths.
In either vb.net of c#:
Can anyone please tell me how to get the full physical path of any of the libraries.
The folders name may be "Pictures" or "Downloads", and what I would like
to access is the full physical path directory for each defined library.
e.g "Pictues" would be say "C:\Users\me\Pictures"
or "Downloads" would be say "C:\Users\me\Downloads"
I have looked a special folders but I cannot see anything that refers to these new "virtual libraries"
Thanks
Loading
krishna vPosted Sep 14, 2010, 1:51 AM
Environment.SpecialFolder gives u access to most of the special folders. Version 4.0 has more folder paths to the earlier verions
Console.WriteLine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic));
Console.WriteLine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=VS.100).aspx
Mike GoldPosted Sep 11, 2010, 10:03 PM
Check out: http://msdn.microsoft.com/en-us/magazine/dd861346.aspx
You can use the following COM call to get the info you want
IShellItem *psi; HRESULT hr = SHGetKnownFolderItem(FOLDERID_PicturesLibrary, KF_FLAG_CREATE, NULL, IID_PPV_ARGS(&psi)); if(SUCCEEDED(hr)) { IShellFolder *psf; hr = psi->BindToHandler(NULL, BHID_SFObject | , IID_PPV_ARGS(&psf)); if(SUCCEEDED(hr)) { IEnumIDList *penumIDList; psf->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS , IID_PPV_ARGS(&penumIDList)); //use penumIDList to enumerate the content of the folder } }
If you are using this in C#, you'll need to use PInvoke to bring in the library API. My guess is it would be easier to write a Visual C++ unmanaged Dll that wraps the above call and returns the path. Then marshal the wrapped call using dllimport and pinvoke.