PageRenderTime 53ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/CSShellKnownFolders/ReadMe.txt

#
Plain Text | 75 lines | 49 code | 26 blank | 0 comment | 0 complexity | 9bd7f064851b5324c07d1ea3f8a0f004 MD5 | raw file
  1. ========================================================================
  2. CONSOLE APPLICATION : CSShellKnownFolders Project Overview
  3. ========================================================================
  4. /////////////////////////////////////////////////////////////////////////////
  5. Use:
  6. The Known Folder system provides a way to interact with certain high-profile
  7. folders that are present by default in Microsoft Windows. It also allows
  8. those same interactions with folders installed and registered with the Known
  9. Folder system by applications. This sample demonstrates those possible
  10. interactions in Visual C# as they are provided by the Known Folder APIs.
  11. A. Enumerate and print all known folders.
  12. B. Print some built-in known folders like FOLDERID_ProgramFiles in two
  13. different ways.
  14. C. Extend known folders with custom folders. (The feature is not demonstrated
  15. in the current sample, because the APIs for extending known folders with
  16. custom folders have not been exposed from Windows API Code Pack for Microsoft
  17. .NET Framework.)
  18. /////////////////////////////////////////////////////////////////////////////
  19. Prerequisites:
  20. Windows API Code Pack for Microsoft .NET Framework
  21. http://code.msdn.microsoft.com/WindowsAPICodePack
  22. /////////////////////////////////////////////////////////////////////////////
  23. Code Logic:
  24. A. Enumerate and print all known folders.
  25. foreach (IKnownFolder kf in KnownFolders.All)
  26. {
  27. Console.WriteLine("{0}: {1}", kf.CanonicalName, kf.Path);
  28. }
  29. B. Print some built-in known folders like FOLDERID_ProgramFiles in two
  30. different ways.
  31. Method 1. Use KnownFolders.ProgramFiles
  32. folder = KnownFolders.ProgramFiles.Path;
  33. Method 2. Use .NET BCL Environment.GetFolderPath
  34. folder = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
  35. C. Extend known folders with custom folders. (The feature is not demonstrated
  36. in the current sample, because the APIs for extending known folders with
  37. custom folders have not been exposed from Windows API Code Pack for Microsoft
  38. .NET Framework.)
  39. /////////////////////////////////////////////////////////////////////////////
  40. References:
  41. MSDN: Working with Known Folders in Applications
  42. http://msdn.microsoft.com/en-us/library/bb776912(VS.85).aspx
  43. MSDN: Default Known Folders in Windows
  44. http://msdn.microsoft.com/en-us/library/dd378457(VS.85).aspx
  45. MSDN: Extending Known Folders with Custom Folders
  46. http://msdn.microsoft.com/en-us/library/bb776910(VS.85).aspx
  47. Windows API Code Pack for Microsoft .NET Framework
  48. http://code.msdn.microsoft.com/WindowsAPICodePack
  49. /////////////////////////////////////////////////////////////////////////////