C#文件directory 操作文件夹与路径、webBrowser、URL、ComboBox
来源:互联网 发布:les小说软件 编辑:程序博客网 时间:2024/05/16 00:49
Directoy:是操作文件夹的,或者是目录
//创建文件夹// 按照指定目录创建文件夹 Directory.CreateDirectory(@"C:\Users\Administrator\Desktop\new"); Directory.CreateDirectory(@"c:\new");//删除文件夹//按照指定目录删除文件夹(前提目录为空) Directory.Delete(@"C:\Users\Administrator\Desktop\new");//后面的true,表示删除其子目录及文件 Directory.Delete(@"C:\Users\Administrator\Desktop\new", true);//获得指定目录下的所有的文件的全路径 string[] name = Directory.GetFiles(@"C:\Users\Administrator\Desktop\something");// 获得指定文件夹的全路径,后缀为.jpg string[] name = Directory.GetFiles(@"C:\Users\Administrator\Desktop\picture","*.jpg");//获得指定目录下所有文件夹的全路径 string[] path = Directory.GetDirectories(@"C:\Users\Administrator\Desktop");//判断指定目录下文件夹是否存在 bool b= Directory.Exists(@"C:\Users\Administrator\Desktop\picture");// 剪切文件夹//源路径和目标路径必须具有相同的根。移动操作在卷之间无效。 Directory.Move(@"C:\Users\Administrator\Desktop\new", @"f:\a"); Directory.Move(@"C:\Users\Administrator\Desktop\new", @"c:\a");
WeBrowser:浏览器
url:导入的地址
private void button1_Click(object sender, EventArgs e) { string str = textBox1.Text; // 将文本框的内容复制到WebBrowser中 Uri uri = new Uri("http://"+str); // 使用URI的构造函数将string类型转换为URI格式 webBrowser1.Url = uri; }
ComboBox
DropDown:控制下拉框的样式
名字一般以cbo 开头
// 将字符串中不想要的字符去掉 string str1 = "1月2月3月4月5月"; string[] ss = str1.Split(new char[] { '月' },StringSplitOptions .RemoveEmptyEntries ); string[] ss1 = str1.Split(new char[] { '月' });
// 整个程序:
private void Form1_Load(object sender, EventArgs e) // form1刚创建时 { //将年份添加到第一个框中 // 获得当前的年份 int thisyear=DateTime .Now .Year ; for (int i = thisyear; i >=1949 ;i-- ) { string year = i + "年"; // 这里不需要再ToString,因为+中,两边只要有一个字符就可以 comYear.Items.Add(year); } } private void comYear_SelectedIndexChanged(object sender, EventArgs e) { // 在选中year后,将月份加入进去 // comYear_SelectedIndexChanged:选中了前面下拉框发生的事件 // 避免每次选中year后,重复添加月份,每次清空 comMonth.Items .Clear (); for (int i = 1; i < 13;i++ ) { string str = i + "月"; comMonth.Items.Add(str); } } private void comMonth_SelectedIndexChanged(object sender, EventArgs e) { // string year = ; comDay.Items.Clear(); string str= comMonth.SelectedItem.ToString(); string[] ss = str.Split(new char[] { '月' },StringSplitOptions .RemoveEmptyEntries );// 后面这个参数不加貌似 也可以 // string[] ss1 = str.Split(new char[] { '月' }); int month =Convert.ToInt32 ( ss[0]); int year = Convert.ToInt32(comYear.SelectedItem.ToString().Split(new char[] { '年' }, StringSplitOptions.RemoveEmptyEntries)[0]); // 在2013年中提取int:2013 int day; switch (month){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: day = 31; break; case 4: case 6: case 9: case 11: day = 30; break; default: if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) day = 29; else day = 28; break; } for (int j = 1; j <= day;j++ ) { comDay.Items.Add("第"+ j + "天"); } }
阅读全文
0 0
- C#文件directory 操作文件夹与路径、webBrowser、URL、ComboBox
- C#操作文件夹Directory
- C#文件与文件夹操作
- Path 路径类 | Directory 文件夹类 | File 文件类 | FileStream 文件流类----------StreamReaded与StreamWriter
- C#文件/文件夹操作
- C#文件、文件夹操作
- 【C#学习杂记】Directory获取文件路径
- C#获取文件名 文件路径 文件夹路径
- c#路径文件操作
- Directory文件夹相关操作
- C# 操作文件夹及文件
- C# 操作文件夹及文件
- C# 操作文件夹及文件
- C# 操作文件夹及文件
- C# 文件,文件夹的操作
- C#操作文件以及文件夹
- C#文件和文件夹操作
- C#常用 文件、文件夹 操作
- Magento2命令行配置之性能测试生成数据
- Qt image load path
- 20170529:初学spring的小总结
- bzoj 1601: [Usaco2008 Oct]灌水 (最小生成树)
- Java中数组的clone方法为什么是浅复制
- C#文件directory 操作文件夹与路径、webBrowser、URL、ComboBox
- USACO-Section 1.2 Palindromic Squares[...]
- 重要参考:互联网金融MySQL优化参数标准
- 上下界网络流
- [LeetCode] Edit Distance
- jsp三大编译指令
- JSTL标签初探
- 通达OA 商务平台OA2017新版本简易评测(图文)
- C# 串行化与反串行化--使用SoapFormatter进行串行化