zoukankan      html  css  js  c++  java
  • Environment.SpecialFolder.CommonApplicationData


    private void button1_Click(object sender, EventArgs e) { var path=Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); MessageBox.Show("路径:"+path); var dir = path + "\edutools\"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Process.Start("explorer.exe",dir); } private void button2_Click(object sender, EventArgs e) { var path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); MessageBox.Show("路径:" + path); var dir = path + "\edutools\"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Process.Start("explorer.exe",dir); } private void button3_Click(object sender, EventArgs e) { var path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); MessageBox.Show("路径:" + path); var dir = path + "\edutools\"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Process.Start("explorer.exe",dir); } private void button4_Click(object sender, EventArgs e) { var path = Environment.GetFolderPath(Environment.SpecialFolder.System); MessageBox.Show("路径:" + path); var dir = path + "\edutools\"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Process.Start("explorer.exe", dir); } private void button5_Click(object sender, EventArgs e) { var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); MessageBox.Show("路径:" + path); var dir = path + "\edutools\"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Process.Start("explorer.exe", dir); } private void button6_Click(object sender, EventArgs e) { var path = Environment.GetFolderPath(Environment.SpecialFolder.Windows); MessageBox.Show("路径:" + path); var dir = path + "\edutools\"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Process.Start("explorer.exe", dir); }

    测试结果:

    在未授予Administrator权限的的Win7 32位上(不打勾,表示无法创建成功):

     

  • 相关阅读:
    在Ubuntu1804上使用Apache2的部署Django配置
    UbuntuServer1804设置uwsgi自启动服务
    ubuntu 安装k8s 1.22.3 (VirtualBox虚拟机)
    启动keepalived 报错
    wasm-pack 编译错误 unexpected character 'u{0}'
    mariadb-安装
    K8S1.18 安装教程
    Ubuntu共享文件权限问题
    docker 安装consul
    Ubuntu 安装 MySQL 和远程连接
  • 原文地址:https://www.cnblogs.com/songxingzhu/p/4269837.html
Copyright © 2011-2022 走看看