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

C# Forms.FileDialog类代码示例

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

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



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

示例1: EditValue

 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if ((provider != null) && (((IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService))) != null))
     {
         if (this.fileDialog == null)
         {
             this.fileDialog = new OpenFileDialog();
             string str = CreateFilterEntry(this);
             for (int i = 0; i < imageExtenders.Length; i++)
             {
             }
             this.fileDialog.Filter = str;
         }
         IntPtr focus = System.Drawing.Design.UnsafeNativeMethods.GetFocus();
         try
         {
             if (this.fileDialog.ShowDialog() == DialogResult.OK)
             {
                 FileStream stream = new FileStream(this.fileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                 value = this.LoadFromStream(stream);
             }
         }
         finally
         {
             if (focus != IntPtr.Zero)
             {
                 System.Drawing.Design.UnsafeNativeMethods.SetFocus(new HandleRef(null, focus));
             }
         }
     }
     return value;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:IconEditor.cs


示例2: CustomOpenFileDialog

		const int DialogWidth = 460; // predefined/desired width
		
		public CustomOpenFileDialog (FileDialog dialog, OpenFileDialogData data)
			: base (dialog)
		{
			Initialize (data);
			
			StartLocation = AddonWindowLocation.Bottom;
		}
开发者ID:louissalin,项目名称:monodevelop,代码行数:9,代码来源:CustomOpenFileDialog.cs


示例3: 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


示例4: 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


示例5: 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


示例6: FileDialogButton

        public FileDialogButton()
        {
            InitializeComponent();

            _dialog = new OpenFileDialog
            {
                Filter = "All files (*.*)|*.*"
            };
        }
开发者ID:ReMinoer,项目名称:FormPlug,代码行数:9,代码来源:FileDialogButton.cs


示例7: STAShowDialog

 private DialogResult STAShowDialog(FileDialog dialog)
 {
     DialogState state = new DialogState();
     state.dialog = dialog;
     System.Threading.Thread t = new System.Threading.Thread(state.ThreadProcShowDialog);
     t.SetApartmentState(System.Threading.ApartmentState.STA);
     t.Start();
     t.Join();
     return state.result;
 }
开发者ID:truonghinh,项目名称:TnX,代码行数:10,代码来源:FrmImportDataFromXml.cs


示例8: OpenFileDialogEx

        public OpenFileDialogEx (FileDialog fileDialog)
        {
			if (fileDialog == null)
				throw new ArgumentNullException ("fileDialog");
			
            InitializeComponent();
//            dlgOpen.AutoUpgradeEnabled = false; 
            //SetStyle(ControlStyles.SupportsTransparentBackColor, true);
			
			this.fileDialog = fileDialog;
        }
开发者ID:hduregger,项目名称:monodevelop,代码行数:11,代码来源:OpenFileDialogEx.cs


示例9: SetFileDialogProperties

        private static void SetFileDialogProperties(FileDialog dialog)
        {
            dialog.Filter = PROJECT_FILTER;

            var recentProjects = Settings.Default.RecentProjects;

            if (recentProjects != null && recentProjects.Count > 0)
            {
                dialog.InitialDirectory = Path.GetDirectoryName(recentProjects[0]);
            }
        }
开发者ID:frankgit,项目名称:NChanges,代码行数:11,代码来源:ApiChangesForm.cs


示例10: Prompts

        public Prompts(OpenFileDialog openDialog, SaveFileDialog saveDialog, ILog log, IEnumerable<IPathStore> store)
        {
            Log = log;
            Stores = store;

            this.openDialog = openDialog;
            this.saveDialog = saveDialog;

            Fallout3Path = TryAllStoresGetPath("Fallout3");
            FalloutNVPath = TryAllStoresGetPath("FalloutNV");
            TTWSavePath = TryAllStoresGetPath("TaleOfTwoWastelands");
        }
开发者ID:WCapelle,项目名称:ttwinstaller,代码行数:12,代码来源:Prompts.cs


示例11: CustomOpenFileDialog

		public CustomOpenFileDialog (FileDialog dialog, OpenFileDialogData data)
			: base (dialog)
		{
			Initialize (data);
			
			StartLocation = AddonWindowLocation.Bottom;

			// Use the classic dialogs, as the new ones (WPF based) can't handle child controls.
			if (data.ShowEncodingSelector || data.ShowViewerSelector) {
				dialog.AutoUpgradeEnabled = false;
			}
		}
开发者ID:segaman,项目名称:monodevelop,代码行数:12,代码来源:CustomOpenFileDialog.cs


示例12: PrepareFileDialog

		private static void PrepareFileDialog(FileDialog dialog, FileDialogCreationArgs args)
		{
			dialog.AddExtension = !string.IsNullOrEmpty(args.FileExtension);
			dialog.DefaultExt = args.FileExtension;
			dialog.FileName = args.FileName;
			dialog.InitialDirectory = args.Directory;
			dialog.RestoreDirectory = true;
			dialog.Title = args.Title;

			dialog.Filter = StringUtilities.Combine(args.Filters, "|",
			                                        f => f.Description + "|" + f.Filter);
		}
开发者ID:jasper-yeh,项目名称:ClearCanvas,代码行数:12,代码来源:ExtendedOpenFilesDialogProvider.cs


示例13: 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


示例14: FileDialog

 /// <summary>
 /// Opens a "FileDialog" prompt window and returns the Dialog Result if blocking, otherwise DialogResult.OK.
 /// Call will block if a delegate isn't passed.
 /// </summary>
 /// <param name="fd">Reference of a FileDialog </param>
 /// <param name="onfinish">If a delegate is passed, then it doesn't block.</param>
 /// <returns></returns>
 public static DialogResult FileDialog(ref FileDialog fd, onDialogFinished onfinish = null)
 {
     DialogResult dr = new DialogResult();
     Oper o = new Oper(ref fd, ref dr) {_callback = onfinish};
     Thread thread = new Thread(() => FileDialog_DoWork(o));
     thread.SetApartmentState(ApartmentState.STA);
     thread.Start();
     if (onfinish != null)
         return DialogResult.OK;
     while (!o._isFinished)
         Thread.Sleep(100);
     return o._dr;
 }
开发者ID:souxiaosou,项目名称:OmniEngine.Net,代码行数:20,代码来源:Dialogs.cs


示例15: extractStrings

 private void extractStrings(FileDialog fileDialog)
 {
     try
     {
         fileLocationAndFileName = fileDialog.FileName;
         fileLocation = Path.GetDirectoryName(fileLocationAndFileName);
         fileName = Path.GetFileName(fileLocationAndFileName);
         _blFileFound = true;
     }
     catch (Exception)
     {
         _blFileFound = false;
     }
 }
开发者ID:yoflippo,项目名称:btlabjackstreamer,代码行数:14,代码来源:FileHandling.cs


示例16: 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


示例17: CreateFile

 private void CreateFile(FileDialog path, dynamic data)
 {
     bool isImage = false;
     Bitmap image = new Bitmap(1,1);
     if (data.GetType().Name == "Bitmap")
     {
         isImage = true;
         image = data;
     }
     using (BinaryWriter br = new BinaryWriter(new FileStream(path, FileMode.OpenOrCreate)))
     {
         if (isImage)
             image.Save(path, System.Drawing.Imaging.ImageFormat.Bmp);
         else
             br.Write(data);
     }
 }
开发者ID:bublyk,项目名称:SretProject,代码行数:17,代码来源:Form1.cs


示例18: 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


示例19: SetCommonFormProperties

		internal static void SetCommonFormProperties (SelectFileDialogData data, FileDialog dialog)
		{
			if (!string.IsNullOrEmpty (data.Title))
				dialog.Title = data.Title;
			
			dialog.AddExtension = true;
			dialog.Filter = GetFilterFromData (data.Filters);
			dialog.FilterIndex = data.DefaultFilter == null ? 1 : data.Filters.IndexOf (data.DefaultFilter) + 1;
			
			dialog.InitialDirectory = data.CurrentFolder;
            if (!string.IsNullOrEmpty (data.InitialFileName))
                dialog.FileName = data.InitialFileName;
			
			OpenFileDialog openDialog = dialog as OpenFileDialog;
			if (openDialog != null)
				openDialog.Multiselect = data.SelectMultiple;
		}
开发者ID:louissalin,项目名称:monodevelop,代码行数:17,代码来源:SelectFileDialogHandler.cs


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Forms.FlowLayoutPanel类代码示例发布时间:2022-05-26
下一篇:
C# Forms.ErrorProvider类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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