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


C# FileDialog.ShowDialog方法代码示例

本文整理汇总了C#中System.Windows.Forms.FileDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# FileDialog.ShowDialog方法的具体用法?C# FileDialog.ShowDialog怎么用?C# FileDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.FileDialog的用法示例。


在下文中一共展示了FileDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: imageOCRTest

 public void imageOCRTest(FileDialog openImageDialog )
 {
     DialogResult ImageResult = openImageDialog.ShowDialog();
      if (ImageResult == DialogResult.OK)
      {
          String testImagePath = openImageDialog.FileName;
          try
          {
              using (var tEngine = new TesseractEngine("C:\\Users\\yeghiakoronian\\Documents\\visual studio 2013\\Projects\\NLP Genre Recogition\\NLP Genre Recogition\\tessdata", "eng", EngineMode.Default)) //creating the tesseract OCR engine with English as the language
              {
                  using (var img = Pix.LoadFromFile(testImagePath)) // Load of the image file from the Pix object which is a wrapper for Leptonica PIX structure
                  {
                      using (var page = tEngine.Process(img)) //process the specified image
                      {
                          String text = page.GetText(); //Gets the image's content as plain text.
                          MessageBox.Show(text);
                          getGenreOfSong(text);
                          //  Console.ReadKey();
                      }
                  }
              }
          }
          catch (IOException)
          {
              MessageBox.Show("Woops Cant Open The File", "COMP 6781: NLP", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
          }
      }
 }
开发者ID:yeghiakoronian,项目名称:MusicGenreClassifier,代码行数:28,代码来源:mainFormFunctions.cs

示例2: AmbilFile

        private void AmbilFile(FileDialog dialog, TextBox control, bool useFilter)
        {
            if (useFilter) { dialog.Filter = "Wave Audio (*.wav)|*.wav"; }
            if (dialog.ShowDialog(this) == DialogResult.OK)

                control.Text = dialog.FileName;
        }
开发者ID:razhou,项目名称:STEGANOGRAPHY-AUDIO-WAV,代码行数:7,代码来源:frmStegano.cs

示例3: StartDialog

		private static DialogResult StartDialog(FileDialog dialog, string extension, string description)
		{
			dialog.AddExtension = true;
			dialog.DefaultExt = extension;
			dialog.Filter = string.Format("{0}(*{1})|*{1}", description, extension);
			var result = dialog.ShowDialog();
			return result;
		}
开发者ID:UnresolvedExternal,项目名称:ImageSearcher,代码行数:8,代码来源:StoreEditor.cs

示例4: FileButtonClick

 private void FileButtonClick(TextBox textBox, FileDialog dialog)
 {
     var result = dialog.ShowDialog();
     if (result == System.Windows.Forms.DialogResult.OK)
     {
         textBox.Text = dialog.FileName;
     }
     else
     {
         textBox.Text = "";
     }
 }
开发者ID:GiveCampUK,项目名称:PPT_2,代码行数:12,代码来源:Form1.cs

示例5: ShowDialogInSTA

        //When calling a OpenFileDialog it needs to be done from an STA thread model otherwise it throws:
        //"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process."
        private static DialogResult ShowDialogInSTA(FileDialog dialog)
        {
            var result = DialogResult.Cancel;

            var thread = new Thread(() =>
                {
                    result = dialog.ShowDialog();
                });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            return result;
        }
开发者ID:ranji,项目名称:NServiceBus,代码行数:17,代码来源:TrialExpired.cs

示例6: DoProcess

        private void DoProcess(string activity)
        {
            try
            {
                if (string.IsNullOrEmpty(Global.SqlLocalDbPath))
                {
                    _dialog = new OpenFileDialog();
                    _dialog.Title = "Locate SqlLocalDB.exe";
                    _dialog.FileName = "SqlLocalDB.exe";
                    _dialog.Filter = "Executable files (*.exe)|*.exe|All files (*.*)|*.*";
                    _dialog.InitialDirectory = Global.SqlLocalDbDefaultPath;
                    _dialog.FilterIndex = 1;
                    if (_dialog.ShowDialog() == DialogResult.OK)
                    {
                        Global.SqlLocalDbPath = "\"" + _dialog.FileName + "\"";
                    }
                }

                var info = new ProcessStartInfo(Global.SqlLocalDbPath, " " + activity + " " + txtInstanceName.Text);
                var p = new Process();
                p.StartInfo = info;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.Start();
                p.WaitForExit();
                var reader = p.StandardOutput;
                var output = reader.ReadToEnd();
                reader.Close();

                if (output.Length == 0)
                {
                    reader = p.StandardError;
                    var error = reader.ReadToEnd();
                    reader.Close();
                    txtResult.Text = error;
                } else {
                    txtResult.Text = output;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:Spiffdog-Design,项目名称:SqlLocalDBManager,代码行数:46,代码来源:SqlManagerForm.cs

示例7: ShowDialogNative

        protected IFileDialogAction ShowDialogNative(FileDialog dlg, Func<Stream> openFile)
        {
            this.AddStarPrefixToExtensions();
            dlg.Filter = this.GetFilter();
            dlg.InitialDirectory = IO.Path.GetDirectoryName(this.FilePath);
            dlg.FileName = IO.Path.GetFileNameWithoutExtension(this.FilePath);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                using (var stream = openFile())
                {
                    if (stream == null)
                        return null;
                    return this.RunAction(dlg.FilterIndex - 1, stream, dlg.FileName);
                }
            }
            return null;
        }
开发者ID:kubaszostak,项目名称:KSz.Shared,代码行数:18,代码来源:AppUI.Forms.cs

示例8: GetFileUrl

        private Uri GetFileUrl(FileDialog dialog, Uri recentUri)
        {
            dialog.Filter = this.FileFilter;

            if (recentUri != null && recentUri.IsFile)
            {
                dialog.FileName = recentUri.LocalPath;
            }

            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                return new Uri(dialog.FileName);
            }
            else
            {
                return null;
            }
        }
开发者ID:otac0n,项目名称:SharpBooks,代码行数:20,代码来源:FilePersistenceStrategy.cs

示例9: Show

        public override WindowResponse Show()
        {
            if (DialogType == FileDialogType.SelectFolder)
            {
                fbdlg = new OpenFolderDialog();
                fbdlg.InitialFolder = InitialDirectory;
                fbdlg.Title = Title;

                WindowResponse resp = WinFormHelper.GetResponse(fbdlg.ShowDialog(owner));
                SelectedPath = fbdlg.Folder;
                return resp;
            }
            else
            {
                switch (DialogType)
                {
                    case FileDialogType.OpenFile:
                        fdlg = new OpenFileDialog();
                        break;
                    case FileDialogType.SaveFile:
                        fdlg = new SaveFileDialog();
                        break;
                }

                fdlg.InitialDirectory = InitialDirectory;
                fdlg.Title = Title;
                string tmpFilter = string.Empty;

                foreach (FileTypeFilter filter in FileTypeFilters)
                {
                    tmpFilter += filter.FilterName + "|";
                    for (int i = 0; i < filter.Filter.Length; i++) tmpFilter += (i == 0 ? "" : ";") + "*." + filter.Filter[i];
                }
                fdlg.Filter = tmpFilter;
                WindowResponse resp = WinFormHelper.GetResponse(fdlg.ShowDialog());
                SelectedPath = fdlg.FileName;
                return resp;
            }
        }
开发者ID:ivynetca,项目名称:lapsestudio,代码行数:39,代码来源:WinFormFileDialog.cs

示例10: salveazaToolStripMenuItem_Click

        private void salveazaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            preiaPoli = new SaveFileDialog();
            preiaPoli.InitialDirectory = @"E:\";
            preiaPoli.Title = "Salveaza poligonul";
            preiaPoli.DefaultExt = ".PNG";
            preiaPoli.CheckPathExists = true;
            preiaPoli.Filter = "Image Files(*.PNG;*.JPG;*.GIF)|*.PNG;*.JPG;*.GIF";

            if (preiaPoli.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image.Save(preiaPoli.FileName);
                MessageBox.Show("Imagine salvata cu succes");
            }
            else if (preiaPoli.ShowDialog() == DialogResult.Cancel)
            {
                pictureBox1.Image = null;
                genereaza.Enabled = true;
                numere.Enabled = true;
                numere.Visible = true;
            }
        }
开发者ID:GeorgianaMihaela,项目名称:polygonFilling,代码行数:22,代码来源:Form1.cs

示例11: ShowFileDialog

        private void ShowFileDialog(
                     FileDialog dialog,
                     string successMessage,
                     string failureMessage,
                     Predicate<string> filePredicate)
        {
            try
            {
                dialog.DefaultExt = "xml";
                dialog.AddExtension = true;
                dialog.Filter = "(*.xml)|*.xml";
                DialogResult result = dialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    string file = dialog.FileName;
                    bool success = filePredicate(file);

                    if (success == true)
                        MessageBox.Show(
                             string.Format(CultureInfo.CurrentCulture,
                                                successMessage,
                                                file));
                    else
                        MessageBox.Show(failureMessage);
                }
            }
            catch (Exception ex)
            {
                Utilities.HandleException(ex);
            }
        }
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:32,代码来源:ClassCleanerOptions.cs

示例12: ShowNonCustomDialogInternal

        /// <summary>
        /// Shows the built in WinForms file dialog instead of the custom dialog. This is because of an
        /// incompatibility in Windows 8.</summary>
        /// <param name="dialog">The instance of the dialog to show</param>
        /// <param name="owner">Dialog owner</param>
        /// <returns>The DialogResult from the file dialog</returns>
        internal protected virtual DialogResult ShowNonCustomDialogInternal(FileDialog dialog, IWin32Window owner)
        {
            // Initialize the dialog settings
            dialog.Filter = m_filter;
            dialog.FilterIndex = m_filterIndex;

            if (!string.IsNullOrEmpty(m_forcedInitialDir))
            {
                dialog.InitialDirectory = m_forcedInitialDir;
            }
            else
            {
                dialog.InitialDirectory = GetLastDirForFilter(m_filter);
            }
            dialog.FileName = m_fileName;
            dialog.Title = m_title;
            
            dialog.CheckFileExists = CheckFileExists;
            dialog.CheckPathExists = CheckPathExists;
            dialog.DereferenceLinks = DereferenceLinks;
            dialog.RestoreDirectory = RestoreDirectory;
            dialog.ValidateNames = ValidateNames;

            if (m_addExt)
            {
                dialog.DefaultExt = m_defaultExt;
            }

            DialogResult result = dialog.ShowDialog(owner);

            if (result == DialogResult.OK)
            {
                // Copy the results back from the dialog.
                m_filterIndex = dialog.FilterIndex;
                if (dialog.FileNames.Length > 1)
                {
                    m_fileNames = new string[dialog.FileNames.Length];
                    for (int i = 0; i < dialog.FileNames.Length; i++)
                    {
                        m_fileNames[i] = dialog.FileNames[i];
                    }
                    m_fileName = m_fileNames[0];
                }
                else
                {
                    m_fileName = dialog.FileName;
                    m_fileNames = new string[] { m_fileName };
                }

                SetLastDirForFilter(m_filter, m_fileName);
            }
            return result;
        }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:59,代码来源:CustomFileDialog.cs

示例13: dinfis_Click

        private void dinfis_Click(object sender, EventArgs e)
        {
            bfisierApasat = true; // am apasat pe din fisier
            umpleFisier = true; // umplem poligon din fisier
            lvarfuri.Enabled = false;
            numere.Enabled = false;

            // nu putem umple cu scanline
            scanLineToolStripMenuItem.Enabled = false;
            //umple.Enabled = true;
            umpleGeneratBound8 = false;
            umpleGeneratBound4 = false;
            umpleGeneratScan = false;

            // deschidem un file dialog
            preiaPoli = new OpenFileDialog();
            preiaPoli.InitialDirectory = @"E:\";
            preiaPoli.Filter = "Image Files(*.PNG;*.JPG;*.GIF)|*.PNG;*.JPG;*.GIF";

            if (preiaPoli.ShowDialog() == DialogResult.OK)
            {
                Image img = Image.FromFile(preiaPoli.FileName); // preluam efectiv imaginea
                poligonFisier = new Bitmap(img);

                pictureBox1.Image = poligonFisier;
                // punem imaginea in centrul picture box
                // pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; asta face o translatie si nu mai
                // e vazuta ok pozitia mouse-ului

            }
        }
开发者ID:GeorgianaMihaela,项目名称:polygonFilling,代码行数:31,代码来源:Form1.cs

示例14: handleDialog

        private void handleDialog(FileDialog fileDialog)
        {
            // Default file extension
            fileDialog.DefaultExt = "*.*";

            // Available file extensions
            fileDialog.Filter = "file Allfiles (*.*)|*.*";

            // Adds a extension if the user does not
            fileDialog.AddExtension = true;

            // Restores the selected directory, next time
            fileDialog.RestoreDirectory = true;

            // Dialog title
            fileDialog.Title = "Geef de locatie van het bestand op";

            // Startup directory
            fileDialog.InitialDirectory = @"C:/";

            fileDialog.ShowDialog();

            extractStrings(fileDialog);
        }
开发者ID:yoflippo,项目名称:btlabjackstreamer,代码行数:24,代码来源:FileHandling.cs

示例15: OpenDatabaseFromDialog

 private void OpenDatabaseFromDialog(FileDialog fileDialog)
 {
     if(CommitChangesCancellable() == DialogResult.Cancel) {
         return;
     }
     db.RollBackChangeSet();
     if(fileDialog.ShowDialog() == DialogResult.OK) {
         LoadDatabase(fileDialog.FileName);
     }
 }
开发者ID:drhoet,项目名称:LanguageTools,代码行数:10,代码来源:MainForm.cs


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