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;
                }
     
  • 相关阅读:
    Java ClassLoader机制
    Spring JMS
    MySQL权限分配
    Java参数传递机制
    JVM装载过程
    PowerDesigner15使用时的十五个问题
    修改当前行 传值
    WebSphere MQ
    Hibernate Search牛刀小试 (转)
    关于hibernate的缓存使用
  • 原文地址:https://www.cnblogs.com/mantian/p/3816834.html
Copyright © 2011-2022 走看看