日期格式化
DateTime.Now.ToString("yyyy-M-d dddd", new CultureInfo("zh-CN"));
打开网页::::: :
View Code
1 private void OpenWeb() 2 { 3 string fileName = "http://www.xxx.com"; 4 try 5 { 6 Process.Start(fileName); 7 } 8 catch 9 { 10 try 11 { 12 Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Internet Explorer\IEXPLORE.EXE"), fileName); 13 } 14 catch 15 { 16 MessageBox.Show("打开网站时出现未知错误。"); 17 } 18 } 19 }打开
private void OpenWeb(string Url) { try { Process.Start(Url); } catch { try { Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Internet Explorer\IEXPLORE.EXE"), Url); } catch { MessageBox.Show("打开网站时出现未知错误。"); } } }
打开计算器
View Code
1 private void RunCalc() 2 { 3 try 4 { 5 Process.Start("calc.exe"); 6 } 7 catch 8 { 9 MessageBox.Show("调用系统计算器时出现错误"); 10 } 11 打开sr
打开文件文件:
Process.Start(Application.StartupPath + @"\readme.txt");
打开记事本:
try { Process.Start("notepad.exe"); } catch { MessageBox.Show("调用系统记事本时出现错误"); }