• 获取指定文件夹的上级目录


    实现效果:

      

    知识运用:

      Directory类的GetParent方法    //检索指定路径的付文件夹   包括绝对路径和相对路径

      public static DirectoryInfo GetParent (string path)

    实现代码:

            private void button1_Click(object sender, EventArgs e)
            {
                FolderBrowserDialog FBDialog = new FolderBrowserDialog();
                if(FBDialog.ShowDialog()==DialogResult.OK)
                {
                    textBox1.Text=FBDialog.SelectedPath;
                    string str1=textBox1.Text;
                    string str2=Directory.GetParent(str1).FullName;
                    string myInfo="当前目录是: "+str1+Environment.NewLine+"上级目录是: "+str2;
                    label2.Text=myInfo;
                }
            }
    

      

  • 相关阅读:
    认证-权限-频率组件
    视图组件
    序列化类
    解析模块
    异常模块
    响应模块分析
    请求模块分析
    cbv请求分析
    django中的restful规范
    web接口与restful规范
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10246529.html
Copyright © 2020-2023  润新知