zoukankan      html  css  js  c++  java
  • WPF

    1. WPF 使用这个方法打开文件,很方便,而且可以记住上次打开的路径。

                Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
                openFileDialog.Multiselect = false;
                openFileDialog.Filter = "AllFiles|*.*";
    
                if ((bool)openFileDialog.ShowDialog())
                {
                    txtPath.Text = openFileDialog.FileName;
                }        
    txtPath 是界面上的控件名称

    想要知道打开文件的历史列表:http://stackoverflow.com/questions/11144770/how-does-wpf-openfiledialog-track-directory-of-last-opened-file
    这个方法应该Work,等需要的时候再深入了。

    2. 当需要将文件另存为的时候,也用这种Win32的函数。用起来也挺方便的。
           Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName = "信息"; // Default file name
                dlg.DefaultExt = ".xlsx"; // Default file extension
                dlg.Filter = "Excel 工作薄 (.xlsx)|*.xlsx"; // Filter files by extension
    
                // Show save file dialog box
                Nullable<bool> result = dlg.ShowDialog();
                string filename = string.Empty;
    
                // Process save file dialog box results
                if (result == true)
                {
                    // Save document
                    filename = dlg.FileName;
                }
                else
                {
                    return;
                }
     
  • 相关阅读:
    Windows多线程编程入门
    多字节字符与宽字符
    Linux静态库与动态库详解
    Linux下清理内存和Cache方法
    数据库设计范式
    mybatis面试问题
    Gson使用
    Linux 定时任务crontab使用
    Java-GC机制
    java内存模型
  • 原文地址:https://www.cnblogs.com/mantian/p/3816834.html
Copyright © 2011-2022 走看看