Can anyone tell me h开发者_运维技巧ow to get the Environment.SpecialFolders.MyVideo
folder in .NET 2.0?
In .NET 4.0, the MyVideo folder is listed in the enum Environment.SpecialFolders
, but under .NET 2.0 it is not existant. Which way would you go if you had to find that folder under .NET 2.0 with different Windows localisations and OS versions?
You'll have to pinvoke SHGetFolderPath yourself. Get the declaration and sample usage from pinvoke.net. Pass 14 for the 2nd argument. Requires at least Windows XP.
To get this directory try this:
DirectoryInfo di = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
string path = di.FullName.Replace(di.Name, "Videos");
精彩评论