Visual C#程序设计技能总结
来源:互联网 发布:win2012更改网络类型 编辑:程序博客网 时间:2024/05/22 15:50
Visual C#程序设计技艺总结
2008-十-04
获取资料的版本信息:
FileVersionInfo myFileVersionInfo一 = FileVersionInfo.GetVersionInfo("D://TEST.DLL");
textBox一.Text="版本号: " + myFileVersionInfo一.FileVersion;
更动资料属性,剔除只读资料:
下例欲将E:/test.txt资料拷贝至D:/tmp/test.txt,但D:/tmp/test.txt已经存在。
//File.Copy(sourceFile,destinationFile,true); 用以拷贝资料
//应destinationFile已经存在时,没法将资料file一拷贝到目标资料,
//因而先剔除destination资料,File.Delete()步骤不能剔除只读资料,
//因而,如其资料属性为只读(Attributes属性中会包孕有"ReadOnly"),
//先把资料属性重置为Normal,其后再剔除:
string file一="E://test.txt";
string destinationFile="d://tmp//test.txt";
if(File.Exists(destinationFile))
{
FileInfo fi=new FileInfo(destinationFile);
if(fi.Attributes.ToString().IndexOf("ReadOnly")!=-一)
fi.Attributes=FileAttributes.Normal;
File.Delete(destinationFile);
}
File.Copy(file一,destinationFile,true);
C#中字符串的格式化及转换成数值的步骤
字符串转换成数目字,例如"1234"转换成数目字1234:
string str="1234";
int i=Convert.ToInt32(str);
格式化字符串,向长度小于30的字符串末后增添特定字符,补足n个字符,运用String种的PadRight(int,char)步骤:
String str="1234";
str=str.PadRight(30,' ') //向长度小于30的字符串终了平添空格,补足30个字符
按行读写资料
判断资料是不是存在:File.Exists(string filePath)
判断索引是不是存在irectory.Exists("D://LastestVersion")
按行读取资料:
int fileCount=零;
// Open the file just specified such that no one else can use it.
StreamReader sr = new StreamReader(textBox一.Text.Trim());
while(sr.Peek() > -一)//StreamReader.Peek()回来下一个可用字符,但不运用它
{
listBox一.Items.Add(sr.ReadLine());
fileCount++;
}
sr.Close();
按行写下资料:
StreamWriter sw = new StreamWriter("D://result.txt");
for(int i=零;i<十;i++)
{
sw.WriteLine("这是第"+i.ToString()+"行数据");
}
资料索引对话框的运用
资料对话框即过滤条件的应用:
string resultFile="";
OpenFileDialog openFileDialog一 = new OpenFileDialog();
openFileDialog一.InitialDirectory = "D://Patch" ;
openFileDialog一.Filter = "All files (*.*)|*.*|txt files (*.txt)|*.txt" ;
openFileDialog一.FilterIndex = 二 ;
openFileDialog一.RestoreDirectory = true ;
if(openFileDialog一.ShowDialog() == DialogResult.OK)
resultFile=openFileDialog一.FileName;
索引对话框的施用:
string resultFolder="";
FolderBrowserDialog openFolderDialog一=new FolderBrowserDialog();
openFolderDialog一.RootFolder=Environment.SpecialFolder.MyComputer;
if(openFolderDialog一.ShowDialog()==DialogResult.OK)
resultFolder=openFolderDialog一.SelectedPath;
本文来源:
我的异常网
Java Exception
Dotnet Exception
Oracle Exception
- Visual C#程序设计技能总结
- Visual C#程序设计技巧小结
- Visual C#程序设计技巧小结
- Visual C#程序设计技巧小结
- C#程序设计总结
- C#程序设计》开发总结
- 《C#程序设计》开发总结
- C#程序设计课程总结
- 下载《Visual C#图像处理程序设计实例》
- 《Visual C# 最佳实践》第一章 程序设计 (一):程序概念
- 《Visual C# 最佳实践》第一章 程序设计 (二):数据类型
- 《Visual C# 最佳实践》第一章 程序设计 (三):变量
- 《Visual C# 最佳实践》第一章 程序设计 (四):运算符
- C#中的泛型程序设计总结
- 《C#程序设计》猜猜看游戏开发总结
- C#程序设计开发总结(猜猜看游戏开发)
- 《Visual C# 2005入门经典》学习总结
- Visual C++ 冒险游戏程序设计
- 基于RBAC模型的权限治理系统的设计和兑现
- C# DataSet和DataTable详解
- 一个怎么展开树节点的方法
- 推荐一个ASP.NET的资源网站
- document属性
- Visual C#程序设计技能总结
- 忆龙2009:iMC或CAMS下发ACL的方法
- WebConfig的经典使用,大家一起交流一下吧!!!
- 树形控件(Tree)的使用
- 一份比较详细的DOS命令说明
- WebService安全解决方案—简单握手协议
- 三层架构+存储过程后台分页+AspNetPager前台分页的经典例子
- memcached
- 忆龙2009:CAMS服务需要开放的端口