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


C# SaveFileDialog.SetPlaces方法代码示例

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


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

示例1: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            if (sender.Equals(_btnSelect))
            {
                using (MyOpenFileDialogControl openDialog = new MyOpenFileDialogControl())
                {
                    if (openDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        lblFilePath.Text = openDialog.MSDialog.FileName;
                    }
                }

            }
            else if (sender.Equals(_btnSave))
            {
                using (MySaveDialogControl saveDialog = new MySaveDialogControl(lblFilePath.Text, this))
                {
                    if (saveDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        lblFilePath.Text = saveDialog.MSDialog.FileName;
                    }
                }
            }
            else if (sender.Equals(this._btnExtension))
            {
                using (MyOpenFileDialogControl openDialogCtrl = new MyOpenFileDialogControl())
                {
                    openDialogCtrl.FileDlgInitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                    OpenFileDialog openDialog = new OpenFileDialog();
                    openDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                    openDialog.AddExtension = true;
                    openDialog.Filter = "Image Files(*.bmp)|*.bmp |Image Files(*.JPG)|*.JPG|Image Files(*.jpeg)|*.jpeg|Image Files(*.GIF)|*.GIF|Image Files(*.emf)|*emf.|Image Files(*.ico)|*.ico|Image Files(*.png)|*.png|Image Files(*.tif)|*.tif|Image Files(*.wmf)|*.wmf|Image Files(*.exif)|*.exif";
                    openDialog.FilterIndex = 2;
                    openDialog.CheckFileExists = true;
                    openDialog.DefaultExt = "jpg";
                    openDialog.FileName = "Select Picture";
                    openDialog.DereferenceLinks = true;
                    //openDialog.ShowHelp = true;
                    if (Environment.OSVersion.Version.Major < 6)
                         openDialog.SetPlaces(new object[] { @"c:\", (int)Places.MyComputer, (int)Places.Favorites, (int)Places.Printers, (int)Places.Fonts });
                    if (openDialog.ShowDialog(openDialogCtrl, this) == DialogResult.OK)
                    {
                        lblFilePath.Text = openDialog.FileName;
                    }
                }
            }
            else if (sender.Equals(_btnSaveExt))
            {
                using (SaveFileDialog saveDialog = new SaveFileDialog())
                {
                    MySaveDialogControl saveDialogCtrl = new MySaveDialogControl(lblFilePath.Text, this);
                    saveDialogCtrl.FileDlgInitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                    saveDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
                    saveDialog.AddExtension = true;
                    saveDialog.Filter = "Image Files(*.bmp)|*.bmp |Image Files(*.JPG)|*.JPG|Image Files(*.jpeg)|*.jpeg|Image Files(*.GIF)|*.GIF|Image Files(*.emf)|*emf.|Image Files(*.ico)|*.ico|Image Files(*.png)|*.png|Image Files(*.tif)|*.tif|Image Files(*.wmf)|*.wmf|Image Files(*.exif)|*.exif";
                    saveDialog.FilterIndex = 2;
                    saveDialog.CheckFileExists = true;
                    saveDialog.DefaultExt = "jpg";
                    saveDialog.FileName = "Change Picture";
                    saveDialog.DereferenceLinks = true;
                    //saveDialog.ShowHelp = true;
                    if (Environment.OSVersion.Version.Major < 6)
                        saveDialog.SetPlaces(new object[] { (int)Places.Desktop, (int)Places.Printers, (int)Places.Favorites, (int)Places.Programs, (int)Places.Fonts, });
                    if (saveDialog.ShowDialog(saveDialogCtrl, this) == DialogResult.OK)
                    {
                        lblFilePath.Text = saveDialog.FileName;
                    }
                }
            }
            else if (sender.Equals(_btnExit))
                this.Close();

            System.GC.Collect();
            GC.WaitForPendingFinalizers();
        }
开发者ID:NoxHarmonium,项目名称:enform,代码行数:75,代码来源:FormMain.cs


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