fileversioninfo myfileversioninfo1 = fileversioninfo.getversioninfo("d://test.dll"); textbox1.text="版本号: " + myfileversioninfo1.fileversion; |
//file.copy(sourcefile,destinationfile,true); 用来拷贝文件 //当destinationfile已经存在时,无法将文件file1拷贝到目标文件, //因此先删除destination文件,file.delete()方法不能删除只读文件, //因此,如果文件属性为只读(attributes属性中会包含有"readonly"), //先把文件属性重置为normal,然后再删除: string file1="e://test.txt"; string destinationfile="d://tmp//test.txt"; if(file.exists(destinationfile)) { fileinfo fi=new fileinfo(destinationfile); if(fi.attributes.tostring().indexof("readonly")!=-1) fi.attributes=fileattributes.normal; file.delete(destinationfile); } file.copy(file1,destinationfile,true); |
string str="1234"; int i=convert.toint32(str); |
string str="1234"; str=str.padright(30,' ') //向长度小于30的字符串末尾添加空格,补足30个字符 |
int filecount=0; // open the file just specified such that no one else can use it. streamreader sr = new streamreader(textbox1.text.trim()); while(sr.peek() > -1)//streamreader.peek()返回下一个可用字符,但不使用它 { listbox1.items.add(sr.readline()); filecount++; } sr.close(); |
streamwriter sw = new streamwriter("d://result.txt"); for(int i=0;i<10;i++) { sw.writeline("这是第"+i.tostring()+"行数据"); } |
string resultfile=""; openfiledialog openfiledialog1 = new openfiledialog(); openfiledialog1.initialdirectory = "d://patch" ; openfiledialog1.filter = "all files (*.*)|*.*|txt files (*.txt)|*.txt" ; openfiledialog1.filterindex = 2 ; openfiledialog1.restoredirectory = true ; if(openfiledialog1.showdialog() == dialogresult.ok) resultfile=openfiledialog1.filename; |
string resultfolder=""; folderbrowserdialog openfolderdialog1=new folderbrowserdialog(); openfolderdialog1.rootfolder=environment.specialfolder.mycomputer; if(openfolderdialog1.showdialog()==dialogresult.ok) resultfolder=openfolderdialog1.selectedpath; |
新闻热点
疑难解答