C# 通过Environment 获取 "我的文档"路径

来源:互联网 发布:机器人编程怎么入门 编辑:程序博客网 时间:2024/06/03 17:04

C# 通过Environment 获取 "我的文档"路径


获取 "我的文档" 路径
public static string GetAbsDirPathInMyDocuments(string dir)        {            dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + dir;            return dir;        }

在Environment类当中 定义了许多特殊文件夹的枚举类型,都可以通过上述方法获取到
public enum SpecialFolder        {            Desktop = 0,            Programs = 2,            Personal = 5,            MyDocuments = 5,            Favorites = 6,            Startup = 7,            Recent = 8,            SendTo = 9,            StartMenu = 11,            MyMusic = 13,            DesktopDirectory = 16,            MyComputer = 17,            Templates = 21,            ApplicationData = 26,            LocalApplicationData = 28,            InternetCache = 32,            Cookies = 33,            History = 34,            CommonApplicationData = 35,            System = 37,            ProgramFiles = 38,            MyPictures = 39,            CommonProgramFiles = 43,        }


0 0