[.NET-Winform]FileDialog的使用方法 |
麦林 发表于 2007/8/10 17:18:28 | 编译dll文件:项目文件为test.cs,生成.DLL文件:csc /target::library /out:: test.dll test.cs/target:library ----指定输入文件是个 DLL,而不是可执行文件(这还将阻止编 译器查找默认入口点)./out:test.dll ---- 指定输出是.dll文件test.cs ---- 表示要编译为dll的文件
判断目录下是否存在文件: string exepath = System.IO.Directory.GetCurrentDirectory(); //获去应用程序所在的路径
if (File.Exists(exepath+"\\lan.exe")) //判断刚获取的路径是否存在lan.exe文件 { return true; } else { return false; }
openFileDialog+saveFileDialog的使用方法:打开:if(this.openFileDialog.ShowDialog(this) == DialogResult.OK) { string tempFilePath = this.filePath; try { this.filePath = this.openFileDialog.FileName; this.historyTextBox.Clear(); this.loadFile(); } catch(Exception) { MessageBox.Show("Sorry! Can't open file!"); this.filePath = tempFilePath; } }保存:if(this.saveFileDialog.ShowDialog(this) == DialogResult.OK) { try { System.IO.File.Delete(this.saveFileDialog.FileName); FileStream fs = new FileStream(this.saveFileDialog.FileName,FileMode.OpenOrCreate , FileAccess.Write,FileShare.ReadWrite); StreamWriter sw = new StreamWriter(fs); sw.Write(this.historyTextBox.Text); sw.Close(); fs.Close(); } catch(Exception) { MessageBox.Show("Sorry! Can't save file!"); } }
|
|
|

.: 公告
|
« | September 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | | | | |
|
.: 我的分类(专题)
|

.: 最新日志
.: 最新回复
|

blog名称:栗色?蓝色? 日志总数:449 评论数量:201 留言数量:37 访问次数:2259417 建立时间:2006年5月16日 |
|

.: 留言板
|

.: 链接
|

|