![]() |
【转帖】vs里调试正常,cad里加载后运行出错,请高手出招
vs里调试正常,cad里加载后运行出错,请高手出招
www.dimcax.com vs里调试正常,cad里加载后运行出错,请高手出招 , , , , // using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; using system.io; using system.data.oledb; using autodesk.autocad.applicationservices; using autodesk.autocad.editorinput; using autodesk.autocad.databaseservices; using autodesk.autocad.geometry; using autodesk.autocad.colors; using system.text.regularexpressions; using system.collections; namespace cxwtool1 { public partial class formdrawline : form { private string pathstring = ""; public formdrawline() { initializecomponent(); } private void groupbox1_enter(object sender, eventargs e) { } private void textbox4_textchanged(object sender, eventargs e) { } /// <summary> ///1、 读数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttongetdata_click(object sender, eventargs e) { this.openfiledialogline.title = "选择数据文件"; this.openfiledialogline.filter = "txt 文件(*.txt)|*.txt|dat 文件(*.dat)|*.dat|excle 文件(*.xls)|*xls|access 文件(*.mdb)|*mdb"; this.openfiledialogline.filename = ""; if (this.openfiledialogline.showdialog() == dialogresult.ok) { string strlengthl = "";//声明变量,表示围岩分段长度 string strinformation = "";//声明变量,表示分段信息 string textstring; int n = 0; //序号累加 pathstring = this.openfiledialogline.filename; this.listview1.items.clear(); if (pathstring.toupper().indexof("dat") > 0 || pathstring.toupper().indexof("txt") > 0) { streamreader sr = new streamreader(pathstring, system.text.encoding.default); // streamreader sr = new streamreader(pathstring); while ((textstring = sr.readline()) != null) { try { textstring = textstring.tostring().trim(); if (textstring.length > 0) { string stridentify = "";//读取分隔符开始 if (textstring.indexof(",") >= 0) { stridentify = ","; } else if (textstring.indexof("\t") > 0) { stridentify = "\t"; } else { stridentify = " "; }//读取分隔符结束 //获取分段长度 int i = textstring.indexof(stridentify); if (i > 0) { strlengthl = textstring.substring(0, i).trim(); textstring = textstring.substring(i + 1).trim(); if (lzxmodel.isnumber(strlengthl)) { strlengthl = convert.todouble(strlengthl).tostring(); } //获取分段信息 i = textstring.indexof(stridentify); if (i > 0) { strinformation = textstring.substring(0, i).trim(); } else { strinformation = textstring; } } else { strlengthl = textstring.trim(); if (lzxmodel.isnumber(strlengthl)) { strlengthl = convert.todouble(strlengthl).tostring(); } else { messagebox.show("分段长度不是数字,请核查"); } strinformation = ""; } n++; listviewitem lv = new listviewitem(n.tostring()); lv.subitems.add(strlengthl); lv.subitems.add(strinformation); listview1.items.add(lv); } } catch (nullreferenceexception) { continue; } } sr.close(); } } } 复制代码 上面的代码没有贴完,现在全部发上来,在附件里 |
所有的时间均为北京时间。 现在的时间是 06:07 AM. |