zoukankan      html  css  js  c++  java
  • C# RestoreDirectory

    RestoreDirectory是控制当前程序中的System.Environment.CurrentDirectory的,也就是,当属性设置为true时,System.Environment.CurrentDirectory永远是程序从中启动的文件夹目录;而设置为false是,则每次使用OpenFileDialog选择完文件后,System.Environment.CurrentDirectory会变成最后一次打开文件的目录。

    OpenFileDialog与SaveFileDialog都有RestoreDirectory属性。

    FolderBrowserDialog 没有RestoreDirectory属性。

    复制代码
    string fName;
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.InitialDirectory = Application.StartupPath ;
    openFileDialog.Filter = "sql文件|*.sql|所有文件|*.*";
    openFileDialog.RestoreDirectory = true;
    openFileDialog.FilterIndex = 1;
    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        fName = openFileDialog.FileName;
        textBoxScript.Text = fName;
    }
    复制代码
    FolderBrowserDialog dialog = new FolderBrowserDialog();
    dialog.Description = "请选择文件路径";
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        textBoxDir.Text = dialog.SelectedPath;
    }
    
    
  • 相关阅读:
    JZOJ 5870 地图
    20190921
    20190919
    SP703 SERVICE
    UVA323 Jury Compromise
    [note]一类位运算求最值问题
    [BZOJ3674]可持久化并查集
    [luogu3359]改造异或树
    [luogu4755]Beautiful Pair
    [BJWC2012]冻结
  • 原文地址:https://www.cnblogs.com/wodewei/p/11687264.html
Copyright © 2011-2022 走看看