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

来源:互联网 发布:王向远 知乎 编辑:程序博客网 时间:2024/05/29 18:30
 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         }

 


<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击