• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Win32.OpenFileDialog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Win32.OpenFileDialog的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Win32.OpenFileDialog类的具体用法?C# Microsoft.Win32.OpenFileDialog怎么用?C# Microsoft.Win32.OpenFileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Microsoft.Win32.OpenFileDialog类属于命名空间,在下文中一共展示了Microsoft.Win32.OpenFileDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: btnMessage_Comment_Browse_Click

        private void btnMessage_Comment_Browse_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ClGlobul.CommentMessagesList.Clear();

                txtCommentMessage.IsReadOnly = true;
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.DefaultExt = ".txt";
                dlg.Filter = "Text documents (.txt)|*.txt";
                Nullable<bool> result = dlg.ShowDialog();
                if (result == true)
                {
                    txtCommentMessage.Text = dlg.FileName.ToString();
                }
                try
                {
                    ClGlobul.CommentMessagesList = GlobusFileHelper.ReadFile(txtCommentMessage.Text.Trim());
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Info(" Please Select File ");
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error :" + ex.StackTrace);
            }
        }
开发者ID:sumitglobussoft,项目名称:pinDominator-3.0,代码行数:29,代码来源:Comment.xaml.cs


示例2: FindFileDialogue

        public FindFileDialogue(string filter)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Set filter for file extension and default file extension
            switch (filter)
            {
                case "csv":
                    dlg.DefaultExt = ".csv";
                    dlg.Filter = "CSV Files (*.csv)|*.csv|All Files |*.*";
                    break;
            }

            // Display OpenFileDialog by calling ShowDialog method
            Nullable<bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                LocationOfFile = filename;
            }
        }
开发者ID:RazaToosy,项目名称:CsvMapper,代码行数:25,代码来源:FindFileDialogue.cs


示例3: OpenFolderOrFile

        private void OpenFolderOrFile(object sender, ExecutedRoutedEventArgs e)
        {
            var dialog = new Microsoft.Win32.OpenFileDialog { CheckFileExists = true, CheckPathExists = true, Multiselect = false };

            if (lastAddedPath != null)
            {
                dialog.FileName = lastAddedPath;
            }

            var ret = dialog.ShowDialog(this);
            if (ret.HasValue && ret.Value)
            {
                lastAddedPath = dialog.FileName;

                string filename = null;
                if (File.Exists(lastAddedPath))
                {
                    filename = lastAddedPath;
                    lastAddedPath = Path.GetDirectoryName(lastAddedPath);
                }
                DirectoryController.Scan(lastAddedPath);
                DirectoryController.SelectFile(filename);
                ShowFile();
            }
        }
开发者ID:kevintavog,项目名称:Radish.net,代码行数:25,代码来源:MainWindow.xaml.cs


示例4: cc_Click

        private void cc_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog d = new Microsoft.Win32.OpenFileDialog();
            d.Filter = "JPEG Image (*.JPG)|*.JPG";
               bool? result =  d.ShowDialog(this);
               if (result == true)
               {
               System.IO.FileInfo fi = new System.IO.FileInfo(d.FileName);
               //fi.CopyTo("..\\..\\Resources\\"+fi.Name,true);
               XmlDataProvider xdp = this.Resources["BookData"] as XmlDataProvider;
               System.Xml.XmlElement xe = (System.Xml.XmlElement)(e.Source as System.Windows.Controls.ContentControl).Content;
               if (xe["Image"] != null)
               {
                   xe["Image"].InnerText = fi.FullName;
                   //System.Xml.XmlTextWriter xr = new System.Xml.XmlTextWriter(new System.IO.FileStream(@"C:\a.txt", System.IO.FileMode.OpenOrCreate), Encoding.Unicode);
                   //xe.WriteTo(xr);
                   //xr.Close();

               }
               else
               {
                   System.Xml.XPath.XPathNavigator navigator = xe.CreateNavigator();
                   navigator.AppendChildElement(null, "Image", null, fi.FullName);
                   this.listBox.Items.Refresh();
               }
               }
        }
开发者ID:powernick,项目名称:CodeLib,代码行数:27,代码来源:MainWindow.xaml.cs


示例5: Button_Click_1

 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     var ofd = new Microsoft.Win32.OpenFileDialog();
     var result = ofd.ShowDialog();
     if (result == false) return;
     nombreArchivo.Text = ofd.FileName;
 }
开发者ID:AaronRevilla,项目名称:TT_2012b-049_ComputerGraphics,代码行数:7,代码来源:DrawLines.xaml.cs


示例6: LoadTests

 private void LoadTests()
 {
     var fileDialog = new Microsoft.Win32.OpenFileDialog
     {
         FileName = "../../tests.txt"
     };
     try
     {
         var fileLines = File.ReadAllLines(fileDialog.FileName);
         foreach (string line in fileLines)
         {
             var sample = new Sample
             {
                 Cells = new int[Globals.GridSize]
             };
             var splitedLine = line.Split(' ');
             int j;
             for (j = 0; j < Globals.GridSize; j++)
             {
                 sample.Cells[j] = Convert.ToInt32(splitedLine[j]);
             }
             sample.Digit = splitedLine[j];
             _samples.Add(sample);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
 }
开发者ID:Pawel-Marcin-Chojnacki,项目名称:Wstep-do-sieci-neuronowych,代码行数:30,代码来源:MainWindow.xaml.cs


示例7: btn_MentionUsers_BrowseMessage_Click

        private void btn_MentionUsers_BrowseMessage_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.DefaultExt = ".txt";
                dlg.Filter = "Text documents (.txt)|*.txt";
                Nullable<bool> result = dlg.ShowDialog();
                if (result == true)
                {
                    this.Dispatcher.Invoke(new Action(delegate
                    {
                        txt_MentionUser_LoadMessage_MessageFilePath.Text = dlg.FileName;
                    }));

                    List<string> tmpList = Globussoft.GlobusFileHelper.ReadFiletoStringList(dlg.FileName);
                    GlobalDeclration.objMentionUser.listOfMessageToComment = tmpList.Distinct().ToList();

                    GlobusLogHelper.log.Info(tmpList.Count + " Urls Uploaded ");

                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error ==> " + ex.Message);
            }
        }
开发者ID:sumitglobussoft,项目名称:GramDominator-2.0,代码行数:27,代码来源:UserControlMentionUserLoadMessage.xaml.cs


示例8: btnPinUrls_Like_Browse_Click

        private void btnPinUrls_Like_Browse_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                txtLikePinUrl.IsReadOnly = true;
                ClGlobul.lstAddToBoardUserNames.Clear();
                Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
                ofd.DefaultExt = ".txt";
                ofd.Filter = "Text documents (.txt)|*.txt";
                Nullable<bool> result = ofd.ShowDialog();

                if (result == true)
                {
                    txtLikePinUrl.Text = ofd.FileName.ToString();
                    Thread ReadLargeFileThread = new Thread(ReadLargeLikePinUrlsFile);
                    ReadLargeFileThread.Start(ofd.FileName);
                    ClGlobul.lstAddToBoardUserNames = GlobusFileHelper.ReadFile(txtLikePinUrl.Text.Trim());
                    GlobusLogHelper.log.Info(" => [ " + ClGlobul.lstAddToBoardUserNames.Count + " Pin Urls Uploaded ]");
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Info("Error :" + ex.StackTrace);
            }
        }
开发者ID:sumitglobussoft,项目名称:pinDominator-3.0,代码行数:25,代码来源:Like.xaml.cs


示例9: btLoad_Click

        private void btLoad_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();

            dialog.FileOk += dialog_FileOk;
            dialog.ShowDialog();
        }
开发者ID:abatista667,项目名称:App-Code-Generator,代码行数:7,代码来源:MainWindow.xaml.cs


示例10: btnSource_Click

        private void btnSource_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.FileName = "Select File to Convert";

            Nullable<bool> result = openFileDialog.ShowDialog();

            if (result == true)
            {
                entSource.Text = openFileDialog.FileName.ToLower();
                if (!(entSource.Text.EndsWith(".shp") ||
                       entSource.Text.EndsWith(".kml")))
                {
                    entSource.Text = "Extension Must be SHP or KML";
                    btnConvert.IsEnabled = false;
                }

                else
                {
                    if (entDestination.Text.EndsWith(".shp") ||
                           entDestination.Text.EndsWith(".kml"))
                    {
                        btnConvert.IsEnabled = true;
                    }
                }
            }
        }
开发者ID:adakkak,项目名称:Chomo,代码行数:27,代码来源:Window1.xaml.cs


示例11: BT_AddImage_Click

        private void BT_AddImage_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();

            dialog.DefaultExt = ".jpeg";
            dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";

            Nullable<bool> result = dialog.ShowDialog();

            if (result == true)
            {

                CB_Images.Items.Add(dialog.FileName.ToString());
                IMG_SelectedImage.Source = CloneImage(dialog.FileName.ToString());
                imageSource.Add(dialog.FileName.ToString());
                imageCaptions.Add("");

                if( (CB_Images.Items.Count-1)  == 0 )
                {
                    CB_Images.SelectedIndex = 0;
                }
                else
                {
                    CB_Images.SelectedIndex = CB_Images.Items.Count - 1;
                }
            }
        }
开发者ID:Neeelsie,项目名称:REII422_DesktopApp,代码行数:27,代码来源:AddListingView.xaml.cs


示例12: ImportProtectedKey

        ///<summary>
        /// Imports a protected key from a file and updates a <see cref="ProtectedKeySettings"/> structure with the imported values.
        ///</summary>
        ///<param name="uiService">The user-interface service for displaying messages and windows to the user.</param>
        ///<param name="keySettings">The key settings structure to update.</param>
        public static void ImportProtectedKey(IUIServiceWpf uiService, ProtectedKeySettings keySettings)
        {
            string protectedKeyFilename = keySettings.FileName;
            DataProtectionScope protectedKeyScope = keySettings.Scope;

            if (!File.Exists(protectedKeyFilename))
            {
                var dialogResult = uiService.ShowMessageWpf(
                                        string.Format(CultureInfo.CurrentCulture, Resources.MessageboxMessageUnableToLocateCryptoKey, keySettings.FileName),
                                        Resources.MessageboxTitleUnableToLocateCryptoKey,
                                        System.Windows.MessageBoxButton.YesNo);
                if (dialogResult == System.Windows.MessageBoxResult.Yes)
                {

                    Microsoft.Win32.OpenFileDialog locateCryptoKeyDialog = new Microsoft.Win32.OpenFileDialog
                    {
                        Title = Resources.MessageboxTitleUnableToLocateCryptoKey
                    };

                    var locateFileDislogresult = uiService.ShowFileDialog(locateCryptoKeyDialog);
                    if (true == locateFileDislogresult.DialogResult)
                    {
                        protectedKeyFilename = locateCryptoKeyDialog.FileName;
                    }
                }
            }

            using (Stream keyFileContents = File.OpenRead(protectedKeyFilename))
            {
                var key = KeyManager.Read(keyFileContents, protectedKeyScope);
                keySettings.ProtectedKey = key;
                keySettings.Scope = protectedKeyScope;
                keySettings.FileName = protectedKeyFilename;
            }
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:40,代码来源:KeyManagerUtilities.cs


示例13: btnBrowse_Click

        //<< --------------------------   >>//
        private void btnBrowse_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();



            // Set filter for file extension and default file extension 
            dlg.DefaultExt = ".jpg";
            dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";


            // Display OpenFileDialog by calling ShowDialog method 
            Nullable<bool> result = dlg.ShowDialog();


            // Get the selected file name and display in a TextBox 
            if (result == true)
            {
                // Open document 
                string filename = dlg.FileName;
                lblFilename.Content = filename;
                imgCategoryImage.Source = new BitmapImage(new Uri(filename));
            }

        }
开发者ID:NaveenSinghKhatri,项目名称:POS-WPF,代码行数:26,代码来源:Window4.xaml.cs


示例14: menuItemFileOpen_Click

        private void menuItemFileOpen_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openXmlFileDialog = new Microsoft.Win32.OpenFileDialog();
            openXmlFileDialog.DefaultExt = "xml";
            openXmlFileDialog.Filter = "XML(.xml)|*.xml";
            //show dialog
            Nullable<bool> result = openXmlFileDialog.ShowDialog();

            //wait the result
            if (result == true && openXmlFileDialog.FileName != "")
            {
                try
                {
                    //http://blog.csdn.net/zengjibing/archive/2009/01/16/3797837.aspx
                    XmlDocument answerXmlSource = new XmlDocument();
                    answerXmlSource.Load(openXmlFileDialog.FileName);
                    XmlDataProvider answerXmlprovider = this.FindResource("answerXmlDoc") as XmlDataProvider;
                    answerXmlprovider.Document = answerXmlSource;
                    answerXmlprovider.XPath = "/ArrayOfQuestion/Question";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                
            }
        }
开发者ID:juyingnan,项目名称:VS,代码行数:27,代码来源:MainWindow.xaml.cs


示例15: OnCommand

        private void OnCommand()
        {
            // Configure open file dialog box
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            //dlg.FileName = "Document"; // Default file name
            dlg.DefaultExt = ".jws"; // Default file extension
            dlg.Filter = "Jade Workspace files (.jws)|*.jws"; // Filter files by extension
            dlg.CheckFileExists = true;
            dlg.CheckPathExists = true;

            // Show open file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;

                try
                {
                    JadeData.Workspace.IWorkspace workspace = JadeData.Persistence.Workspace.Reader.Read(filename);
                    _viewModel.Workspace = new JadeControls.Workspace.ViewModel.Workspace(workspace);
                }
                catch (System.Exception e)
                {

                }
            }
        }
开发者ID:JadeHub,项目名称:Jade,代码行数:30,代码来源:OpenWorkspace.cs


示例16: UpdateThumbnail

    public void UpdateThumbnail(object sender, EventArgs e)
    {
      Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
      dlg.FileName = ""; // Default file name
      dlg.DefaultExt = ".png"; // Default file extension
      dlg.Filter = "Image Files(*.PNG;*.JPG;*.BMP;*.GIF)|*.PNG;*.JPG;*.BMP;*.GIF|All files (*.*)|*.*";

      Nullable<bool> result = dlg.ShowDialog();
      if (true == result)
      {
        if (null != dlg.FileName && 0 < dlg.FileName.Length && File.Exists(dlg.FileName))
        {
          // loadimage
          try
          {
            // fetch via URL
            Uri imageUri = new Uri(dlg.FileName);
            BitmapDecoder bmd = BitmapDecoder.Create(imageUri, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);

            // reset width
            ThumbnailImage.Width = double.NaN;

            // set the source
            _thumbnailImage.Source = bmd.Frames[0];
            _isDefault = false;
          }
          catch (Exception) { /* noop */ }
        }
      }
    }
开发者ID:Innovate-Inc,项目名称:EMEMetadataToolKit,代码行数:30,代码来源:ItemInfo.xaml.cs


示例17: openList_Click

        private void openList_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Filter = "mp3 files (*.mp3)|*.mp3";
            dlg.DefaultExt = "mp3";
            dlg.Title = "Browse MP3 Files";
            dlg.Multiselect = true;

            if(player.IsInit){
                // Display OpenFileDialog by calling ShowDialog method
                Nullable<bool> result = dlg.ShowDialog();
                if (result == true)
                {
                    List<String> paths = new List<string>();
                    
                    foreach (String file in dlg.FileNames)
                    {
                        paths.Add(file);
                        char[] st = {'\\'};
                        String[] name = file.Split(st);
                        //MessageBox.Show(name[name.Length - 1]);
                        listBox1.Items.Add(name[name.Length - 1]);
                    }

                    listBox1.Tag = paths;
                }
            }
        }
开发者ID:MilosSimic,项目名称:snakeRoot,代码行数:28,代码来源:MainWindow.xaml.cs


示例18: ChoosePackageDialog

        private void ChoosePackageDialog()
        {
            // Configure open file dialog box 
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName = "Document"; // Default file name 
            dlg.DefaultExt = ".AGT"; // Default file extension 
            dlg.Filter = "Agent Package (.agt)|*.agt"; // Filter files by extension 

            // Show open file dialog box 
            Nullable<bool> result = dlg.ShowDialog();

            // Process open file dialog box results 
            if (result == true)
            {
                // Open document 
                PackageSource = dlg.FileName;

                ICSharpCode.SharpZipLib.Zip.FastZip fz = new FastZip();

                var root = System.IO.Path.Combine(System.IO.Path.GetTempPath(), (Guid.NewGuid().ToString()));

                fz.ExtractZip(PackageSource, root, FastZip.Overwrite.Always, null, null, null, true);

                PackageFile = System.IO.Path.Combine(root, "package.json");

                if (System.IO.File.Exists(PackageFile))
                {
                    var cnt =  System.IO.File.ReadAllText(PackageFile);
                    Contents = cnt;
                }
            }
        }
开发者ID:nothingmn,项目名称:AGENT.Contrib,代码行数:32,代码来源:PackageViewerViewModel.cs


示例19: BrowseWaitingListButton_Click

        private void BrowseWaitingListButton_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            if (!string.IsNullOrEmpty(WaitingListFileTextBox.Text))
            {
                string dir = System.IO.Path.GetDirectoryName(WaitingListFileTextBox.Text);
                if (Directory.Exists(dir))
                {
                    dlg.InitialDirectory = dir;
                }
            }

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".csv";
            dlg.Filter = "CSV Files (*.csv)|*.csv";

            // Display OpenFileDialog by calling ShowDialog method
            Nullable<bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                WaitingListFileTextBox.Text = dlg.FileName;
            }
        }
开发者ID:palbitz1003,项目名称:CMGC,代码行数:27,代码来源:SignupTab.xaml.cs


示例20: PowerPointControl

        public PowerPointControl()
        {
            // OpenFileDialog Instanz erzeugen
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            // Dateiendungs-Filter setzen
            dlg.DefaultExt = ".pptx";
            dlg.Filter = "Powerpoint|*.ppt;*.pptx|All files|*.*";

            // OpenFileDialog anzeigen
            Nullable<bool> result = dlg.ShowDialog();

            // PowerPoint Instanz erzeugen
            oPPT = new Microsoft.Office.Interop.PowerPoint.Application();
            // PowerPoint anzeigen
            oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
            objPresSet = oPPT.Presentations;

            // Wenn der Benutzer im OpenFileDialog eine Datei ausgewählt + auf OK geklickt hat
            if (result == true)
            {
                // Ausgewählte Datei (Präsentation) öffnen
                objPres = objPresSet.Open(dlg.FileName, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);

                // Präsentationsansicht öffnen
                objPres.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
                System.Diagnostics.Debug.WriteLine(objPres.SlideShowSettings.ShowWithAnimation);
                objPres.SlideShowSettings.Run();

                oSlideShowView = objPres.SlideShowWindow.View;
            }
        }
开发者ID:KinAudio,项目名称:Master,代码行数:32,代码来源:PowerPointControl.cs



注:本文中的Microsoft.Win32.OpenFileDialog类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Win32.SaveFileDialog类代码示例发布时间:2022-05-24
下一篇:
C# Web.Administration类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap