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

C# Forms.OpenFileDialog类代码示例

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

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



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

示例1: btnNew_Click

        private void btnNew_Click(object sender, EventArgs e)
        {
            // 获取文件夹绝对路径    显示在 txtbox 控件里

            System.Windows.Forms.FolderBrowserDialog folder = new System.Windows.Forms.FolderBrowserDialog();

            string StrFileName = "";
            // 获取文件和路径名 一起显示在 txtbox 控件里

            OpenFileDialog dialog = new OpenFileDialog();
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string SavePathFile = AppDomain.CurrentDomain.BaseDirectory + "\\image\\gdc" +DateTime.Now.ToString("yyyyMMddHHmmss")+ ".jpg";
                StrFileName = dialog.SafeFileName;
                if (File.Exists(SavePathFile))
                {
                    File.Delete(SavePathFile);
                } File.Copy( dialog.FileName,SavePathFile);
                if (!db.InsertH_Para("H_gdc", "gdc" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg", db.GetMaxID("gdc", "H_gdc")))
                {
                    MessageBox.Show("保存失败!"); return;
                }
                else
                {
                    MessageBox.Show("保存成功!");
                    ShowDt(PageInt);
                }
            }
        }
开发者ID:SpiderLoveFish,项目名称:HZLApp,代码行数:29,代码来源:gdc.cs


示例2: button3_Click

 private void button3_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count != 1)
         return;
     OpenFileDialog od = new OpenFileDialog();
     od.Filter = "Bitmap file (*.bmp)|*.bmp";
     od.FilterIndex = 0;
     if (od.ShowDialog() == DialogResult.OK)
     {
         Section s = listView1.SelectedItems[0].Tag as Section;
         try
         {
             Bitmap bmp = new Bitmap(od.FileName);
             s.import(bmp);
             bmp.Dispose();
             pictureBox1.Image = s.image();
             listView1.SelectedItems[0].SubItems[3].Text = s.cnt.ToString();
             button4.Enabled = true;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
开发者ID:winterheart,项目名称:game-utilities,代码行数:25,代码来源:Form1.cs


示例3: OpenFile

 /// <summary>
 /// Open a new file. Will ask for the file name in a dialog.
 /// </summary>
 public void OpenFile()
 {
     OpenFileDialog dlg = new OpenFileDialog ();
     if (dlg.ShowDialog () == DialogResult.OK)
         OpenFile (dlg.FileName);
     dlg.Dispose ();
 }
开发者ID:NALSS,项目名称:Telegraph,代码行数:10,代码来源:TextEditor.cs


示例4: OnClickSelect

        private void OnClickSelect(object sender, EventArgs e)
        {
            DicomFile file1 = null;
            while (true)
            {
                var ofd = new OpenFileDialog();
                ofd.Title = "Choose first DICOM file";
                ofd.Filter = "DICOM Files (*.dcm;*.dic)|*.dcm;*.dic|All Files (*.*)|*.*";

                if (ofd.ShowDialog(this) == DialogResult.Cancel) return;

                try
                {
                    file1 = DicomFile.Open(ofd.FileName);
                    break;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        this,
                        ex.Message,
                        "Error opening DICOM file",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }

            DicomFile file2 = null;
            while (true)
            {
                var ofd = new OpenFileDialog();
                ofd.Title = "Choose second DICOM file";
                ofd.Filter = "DICOM Files (*.dcm;*.dic)|*.dcm;*.dic|All Files (*.*)|*.*";

                if (ofd.ShowDialog(this) == DialogResult.Cancel) return;

                try
                {
                    file2 = DicomFile.Open(ofd.FileName);
                    break;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        this,
                        ex.Message,
                        "Error opening DICOM file",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }

            _file1 = file1;
            _file2 = file2;

            lblFile1.Text = _file1.File.Name;
            lblFile2.Text = _file2.File.Name;

            CompareFiles();
        }
开发者ID:gustavosaita,项目名称:fo-dicom,代码行数:60,代码来源:MainForm.cs


示例5: OpenToolStripMenuItemClick

        private void OpenToolStripMenuItemClick(object sender, EventArgs e)
        {
            var dataPlanOpenFileDialog = new OpenFileDialog
                                             {
                                                 Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*",
                                                 FilterIndex = 1,
                                                 Multiselect = false,
                                                 RestoreDirectory = true
                                             };

            if (dataPlanOpenFileDialog.ShowDialog() != DialogResult.OK)
                return;

            try
            {
                if (File.Exists(dataPlanOpenFileDialog.FileName))
                {
                    _file = dataPlanOpenFileDialog.FileName;
                    Text = _file;
                    LoadDataPlan(DataPlan.Load(dataPlanOpenFileDialog.FileName));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
            }
        }
开发者ID:geniuslinda,项目名称:nDump,代码行数:27,代码来源:MainForm.cs


示例6: AttachMenuStripEventHandlers

        /// <summary>
        /// Attaches event handlers related to 
        /// </summary>
        private void AttachMenuStripEventHandlers()
        {
            // File
            tsmNewProject.Click += (@s, e) => NewProject();
            tsmOpenProject.Click += (@s, e) => LoadProject();

            // Edit

            // View
            tsmShowStartPage.Click += (@s, e) => StartPage.Instance.Show(dockPanel);
            tsmShowProjectExplorer.Click += (@s, e) => ResourceExplorer.Instance.Show(dockPanel);

            // Project
            tsmImportResource.Click += (@s, e) =>
                {
                    var dialog = new OpenFileDialog();
                    dialog.Filter = "Image File (*.jpg;*.png)|*.jpg;*.png|Animated Image File (*.gif)|*.gif|Animat Resource (*.amt)|*.amt|BarloX Animation (*.bxa;*.ibxa)|*.bxa;*.ibxa";
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        AnimatProject.Instance.ImportResource(dialog.FileName);
                    }
                };

            // Help
            tsmAbout.Click += (@s, e) =>
                    AboutWindow.Instance.Show(dockPanel, DockState.Document);
        }
开发者ID:r1cebank,项目名称:AmiMat,代码行数:30,代码来源:MainForm.Events.cs


示例7: LoadNewPlugin

        public static void LoadNewPlugin(IAutoWikiBrowser awb)
        {
            OpenFileDialog pluginOpen = new OpenFileDialog();
            if (string.IsNullOrEmpty(LastPluginLoadedLocation))
                LoadLastPluginLoadedLocation();

            pluginOpen.InitialDirectory = string.IsNullOrEmpty(LastPluginLoadedLocation) ? Application.StartupPath : LastPluginLoadedLocation;
            
            pluginOpen.DefaultExt = "dll";
            pluginOpen.Filter = "DLL files|*.dll";
            pluginOpen.CheckFileExists = pluginOpen.Multiselect = /*pluginOpen.AutoUpgradeEnabled =*/ true;

            pluginOpen.ShowDialog();
            
            if (!string.IsNullOrEmpty(pluginOpen.FileName))
            {
                string newPath = Path.GetDirectoryName(pluginOpen.FileName);
                if (LastPluginLoadedLocation != newPath)
                {
                    LastPluginLoadedLocation = newPath;
                    SaveLastPluginLoadedLocation();
                }
            }

            Plugin.LoadPlugins(awb, pluginOpen.FileNames, true);
        }
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:26,代码来源:PluginManager.cs


示例8: OpenDialog

 public void OpenDialog(bool multipleFiles, params FileTypes[] fileTypes)
 {
     ofd = new OpenFileDialog();
     ofd.Multiselect = multipleFiles;
     ofd.Filter = Utils.FileTypesToWinFormFilter(fileTypes);
     result = ofd.ShowDialog();
 }
开发者ID:JacquesLucke,项目名称:Collage,代码行数:7,代码来源:OpenFileWindow.cs


示例9: openToolStripMenuItem_Click

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Multiselect = false;
            dialog.Filter = "All Supported Files |*.csv;*.txt;*.xls;*.xlsx;*.docx;*.rtf;*.eml;*.xml;*.html;*.htm;*.doc;*.ppt;*.pptx;*.cnm;*.vsd;*.pdf;*.vcf;*.zip;*.mp3;*.ape;*.wma;*.flac;*.aif;*.jpeg;*.jpg;*.tiff;*.png;*.gif";
            dialog.Filter += "|Comma Seperated Files (*.csv)|*.csv";
            dialog.Filter += "|Audio Files|*.mp3;*.ape;*.wma;*.flac;*.aif";
            dialog.Filter += "|Image Files|*.jpeg;*.jpg;*.tiff;*.png;*.gif";
            dialog.Filter += "|Zip Package|*.zip";
            dialog.Filter += "|Text Files (*.txt)|*.txt";
            dialog.Filter += "|Excel Documents|*.xls;*.xlsx";
            dialog.Filter += "|Rich Text Files (*.rtf)|*.rtf";
            dialog.Filter += "|Word Documents|*.docx;*.doc";
            dialog.Filter += "|PowerPoint Documents|*.ppt;*.pptx";
            dialog.Filter += "|Business Card Files (*.vcf)|*.vcf";
            dialog.Filter += "|Email Files (*.eml)|*.eml";
            dialog.Filter += "|Html Files (*.html, *.htm)|*.html;*.htm";
            dialog.Filter += "|XML Files (*.xml)|*.xml";
            dialog.Filter += "|Adobe PDF Files (*.pdf)|*.pdf";
            dialog.Filter += "|Pegsus Mailbox file (*.cnm)|*.cnm";

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                filepath = dialog.FileName;
            }

            OpenFile(filepath, comboBox1.Text);
        }
开发者ID:iraychen,项目名称:toxy,代码行数:28,代码来源:Form1.cs


示例10: InitializeDialog

        protected override void InitializeDialog(OpenFileDialog openFileDialog)
        {
            base.InitializeDialog(openFileDialog);

            openFileDialog.CheckFileExists = false;
            openFileDialog.Filter = "Microsoft Office Access (*.mdb)|*.mdb";
        }
开发者ID:drme,项目名称:disks-db,代码行数:7,代码来源:DbFileNameEditor.cs


示例11: loadButton_Click

        private void loadButton_Click(object sender, EventArgs e)
        {
            string toneSavePath;
            using (var ofd = new OpenFileDialog())
            {
                ofd.Filter = CurrentOFDFilter;
                if (ofd.ShowDialog() != DialogResult.OK) return;
                toneSavePath = ofd.FileName;
            }

            try
            {
                switch (CurrentGameVersion)
                {
                    case GameVersion.RS2012:
                        toneControl1.Tone = Tone.LoadFromXmlTemplateFile(toneSavePath);
                        break;
                    case GameVersion.RS2014:
                        toneControl1.Tone = Tone2014.LoadFromXmlTemplateFile(toneSavePath);
                        break;
                }

            }
            catch (Exception ex)
            {
                toneControl1.Tone = null;
                MessageBox.Show("Can't load saved tone. \n" + ex.Message, DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            MessageBox.Show("Tone was loaded.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
开发者ID:ray,项目名称:rocksmith-custom-song-toolkit,代码行数:32,代码来源:ToneForm.cs


示例12: Setup

 private void Setup()
 {
     var configSetup = new NHibernateConfigSetup();
     if (!configSetup.VerifyNHConfigFileExist())
     {
         if (MessageBox.Show("El archivo de conexión a la base de datos no existe\n" +
                             "para poder hacer uso del sistema por favor importe el archivo.\n\n",
                             "Inventarios",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
         {
             var ofdBuscarArchivo = new OpenFileDialog
                                        {
                                            InitialDirectory = "c:\\",
                                            Filter = "Data files (*.config)|*.config",
                                            FilterIndex = 2,
                                            RestoreDirectory = false
                                        };
             if (ofdBuscarArchivo.ShowDialog() == DialogResult.OK)
             {
                 File.Copy(ofdBuscarArchivo.FileName, "C:\\NHibernateSettings\\" + ofdBuscarArchivo.SafeFileName);
             }
             if (ofdBuscarArchivo.ShowDialog() == DialogResult.Cancel)
             {
                 Application.Exit();
             }
         }
         else
             Application.Exit();
     }
     else
     {
         configSetup.InitializeNHibernate();
         AutoMapperConfiguration.Configure();
     }
 }
开发者ID:giovanirguz,项目名称:SistemaInventarios,代码行数:35,代码来源:FrmMainForm.cs


示例13: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string filePath = ofd.FileName;
                ArcGISTileSource suyTile = new ArcGISTileSource(filePath);
                TileLayer suyTileLyr = new TileLayer(suyTile, "suy");
                //ArcGISTileCompactSource suyTile = new ArcGISTileCompactSource(filePath);
                //ArcGISTileCompactLayer suyTileLyr = new ArcGISTileCompactLayer(suyTile, "suy");
                this.mapImage1.Map.Layers.Add(suyTileLyr);
                this.mapImage1.Map.ZoomToExtents();
                this.mapImage1.Refresh();
                //SharpMap.Data.Providers.SpatiaLite sb = new SharpMap.Data.Providers.SpatiaLite("Data Source=" + ofd.FileName, "water", "Geometry", "PK_UID");
                //VectorLayer vecLyr = new VectorLayer("sqlSpatial");
                //vecLyr.DataSource = sb;
                //this.mapImage1.Map.Layers.Add(vecLyr);
                //this.mapImage1.Map.ZoomToExtents();
                //this.mapImage1.Refresh();

            }
            //BruTile.ITileProvider tileProvider =
            ////BruTile.TileSource ts = new BruTile.TileSource(
            //this.mapImage1.Map.Layers.Add();
        }
开发者ID:F-Sidney,项目名称:SharpMapTileLayer,代码行数:25,代码来源:Form1.cs


示例14: buttonChose_Click

 private void buttonChose_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.ShowDialog();
     textBoxFilePath.Text = ofd.FileName;
     filePath = textBoxFilePath.Text.Trim();
 }
开发者ID:smilelhh,项目名称:TM,代码行数:7,代码来源:InData.cs


示例15: OUVRIR_Click

        private void OUVRIR_Click(object sender, EventArgs e)
        {// permet d'aller chercher dans nos dossier l'image souhaité
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = "c:\\";
            openFileDialog.Filter = "Bitmap files (*.bmp)|*.bmp|Jpeg files (*.jpg)|*.jpg|All valid files (*.bmp/*.jpg)|*.bmp/*.jpg";
            //format prit en compte
            openFileDialog.FilterIndex = 2;
            openFileDialog.RestoreDirectory = true;
        

            if (DialogResult.OK == openFileDialog.ShowDialog())
            {
                
                m_Bitmap = (Bitmap)Bitmap.FromFile(openFileDialog.FileName, false);
                b_Bitmap = (Bitmap)new Bitmap(m_Bitmap);
                this.AutoScroll = true;
                this.AutoScrollMinSize = new Size((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
                
                byte[] pixel_map = this.GetPixelMap(m_Bitmap);
                this.pictureBox2.Image = this.CreatationHistogram(pixel_map);
                // appel la fonction qui permet l'affichage de l'histogramme
                this.comboBox1.Enabled = true;
                this.Invalidate();
                this.Refresh();
            }


        }
开发者ID:jeremyBallot,项目名称:projet_image_Csharp,代码行数:29,代码来源:Form1.cs


示例16: button1_Click

        //select a song
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            timer2.Stop();

            OpenFileDialog dlg = new OpenFileDialog();
            dlg.ShowDialog();
            song_path = dlg.FileName.ToString();
            textBox1.Text = song_path;
            try
            {

                song.Stop();
            }
            catch (Exception ex) { }

            try
            {
                song = new Audio(song_path);
                timer1.Interval = (int)(song.Duration * 10);
                progressBar1.Value = 0;
                //MessageBox.Show(timer1.Interval.ToString());
            }
            catch (Exception ex) { }
        }
开发者ID:githubdemo,项目名称:Voice-controlled-MP3-Player,代码行数:26,代码来源:HomeScreen.cs


示例17: openToolStripMenuItem_Click

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog
            {
                Filter = "JSS document (*.jss)|*.jss|All files (*.*)|*.*",
                Title = "Open document",
            };

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    using (var file = new FileStream(dialog.FileName, FileMode.Open))
                    {
                        var formatter = new BinaryFormatter();
                        var graph = formatter.Deserialize(file) as Graph;
                        if (graph != null)
                        {
                            button1.SetGraph(graph);
                            Filename = dialog.FileName;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error during open: " + ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
开发者ID:kebby,项目名称:jss,代码行数:29,代码来源:Form1.cs


示例18: mnuOpen_OnClick

 void mnuOpen_OnClick(object sender, EventArgs e)
 {
     var dlg = new OpenFileDialog {InitialDirectory = "C:\\", Filter = @"CSV|*.csv"};
     dlg.ShowDialog(this);
     OpenFile(dlg.FileName);
     dlg.Dispose();
 }
开发者ID:daxfohl,项目名称:SudokuCS,代码行数:7,代码来源:Form1.cs


示例19: Main

        static void Main(string[] args)
        {
            OpenFileDialog OpenFile = new OpenFileDialog();
            OpenFile.Multiselect = false;
            OpenFile.Title = "Cartridge";
            OpenFile.Filter = "GBA Files (.gba)|*.gba";
            OpenFile.FilterIndex = 1;

            string Cartridge;

            Console.WriteLine("Gneiss - Game Boy Advance Cartridge Reader.");
            Console.CursorVisible = false;

            if (OpenFile.ShowDialog() == DialogResult.OK)
            {
                Cartridge = OpenFile.FileName;
                BinaryReader BR = new BinaryReader(File.OpenRead(Cartridge));

                BR.BaseStream.Seek(0xA0, SeekOrigin.Begin);
                Console.WriteLine("\n\nCartridge Name: {0}", Encoding.UTF8.GetString(BR.ReadBytes(12)));

                BR.BaseStream.Seek(0xAC, SeekOrigin.Begin);
                Console.WriteLine("Serial: {0}", Encoding.UTF8.GetString(BR.ReadBytes(4)));

                BR.BaseStream.Seek(0x108, SeekOrigin.Begin);
                Console.WriteLine("Name: {0}", Encoding.UTF8.GetString(BR.ReadBytes(24)));
                Console.Read();
            }
        }
开发者ID:Arefu,项目名称:Gneiss,代码行数:29,代码来源:Program.cs


示例20: OnSelectMagneticModel

        private void OnSelectMagneticModel(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Magnetic Model (*.wmm)|*.wmm";
            dlg.DefaultExt = "wmm";

            if (dlg.ShowDialog() == DialogResult.Cancel) return;

            m_path = dlg.FileName.Substring(0, dlg.FileName.LastIndexOf('\\')).Replace('\\', '/');
            int length = dlg.FileName.LastIndexOf('.') - dlg.FileName.LastIndexOf('\\') - 1;
            m_name = dlg.FileName.Substring(dlg.FileName.LastIndexOf('\\') + 1, length);

            try
            {
                m_magnetic = new MagneticModel(m_name, m_path);
                m_magneticModelNameTextBox.Text = dlg.FileName;
                m_nameTextBox.Text = m_magnetic.MagneticModelName;
                m_descriptionTextBox.Text = m_magnetic.Description;
                m_dateTextBox.Text = m_magnetic.DateTime;
                m_updateButton.Enabled = true;
                m_magCircButton.Enabled = true;
                m_validateButton.Enabled = true;
            }
            catch (Exception xcpt)
            {
                MessageBox.Show(xcpt.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:Remdul,项目名称:Circleplot,代码行数:28,代码来源:MagneticPanel.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Forms.POINT类代码示例发布时间:2022-05-26
下一篇:
C# Forms.NumericUpDown类代码示例发布时间: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