现在的位置: 首页 > 综合 > 正文

文件、文件夹、颜色对话框

2013年10月26日 ⁄ 综合 ⁄ 共 827字 ⁄ 字号 评论关闭
 1   string defaultPath = @"C:\Users\Administrator\Desktop\";
 2         public string GetDirPath()
 3         {
 4             FolderBrowserDialog dialog = new FolderBrowserDialog();
 5             dialog.Description = "请选择小图片的文件夹";
 6             dialog.SelectedPath = defaultPath;
 7             if (dialog.ShowDialog() == DialogResult.OK)
 8             {
 9                 defaultPath = dialog.SelectedPath;
10                 return dialog.SelectedPath;
11             }
12             return "";
13         }
14 
15         public string GetFilePath()
16         {
17             OpenFileDialog ofd = new OpenFileDialog();
18             ofd.Filter = "图片文件(*.jpg,*.gif,*.bmp)|*.jpg;*.gif;*.bmp";
19             ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Templates);
20             if (ofd.ShowDialog() == DialogResult.OK)
21             {
22                 return ofd.FileName;
23             }
24             return "";
25 
26         }
27 
28         public Color GetBgColor()
29         {
30             ColorDialog cd = new ColorDialog();
31             cd.AllowFullOpen = true;
32             cd.FullOpen = true;
33             cd.ShowHelp = true;
34             if (cd.ShowDialog() == DialogResult.OK)
35             {
36                 return cd.Color;
37             }
38             return Color.White;
39         }

 

抱歉!评论已关闭.