C#操作实例总结(一)—— 系统操作

判断本机是否联网

if(SystemInformation.Network)
{
    //联网状态
}
else
{
    //未联网状态
}

获取特殊文件路径

获取Program Files路径

string FilePath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

获取桌面目录路径

string FilePath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

获取开始菜单路径

string Filepath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);

获取用户程序组路径

string Filepath = Environment.GetFolderPath(Environment.SpecialFolder.Programs);

获取文档模板路径

string Filepath = Environment.GetFolderPath(Environment.SpecialFolder.Templates);

获取收藏夹路径

string Filepath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

获取共享组件路径

string Filepath = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles);

获取我的图片路径

string Filepath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

获取Internet历史记录路径

string Filepath = Environment.GetFolderPath(Environment.SpecialFolder.History);

获取Internet临时文件路径

string Filepath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);

猜你喜欢

转载自www.cnblogs.com/sunnylux/p/10319666.html