当前位置: 首页>>代码示例>>C#>>正文


C# Win32.OpenFileDialog类代码示例

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


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


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