C_Sharp 板


LINE

原始资料如下 ---- Peak Type a0 a1 a2 a3 1 BG1st[UDF4] 5.83484411 -0.0689749 2 Voigt Amp 1.53274934 -19.800359 0.47166280 0.14278921 Measured Values Peak Type Amplitude Center FWHM Asym50 FW Base 1 BG1st[UDF4] 7.29711128 -21.200000 0.00000000 0.00000000 2 Voigt Amp 1.53274934 -19.800359 0.85969834 1.00000000 Peak Type Anlytc Area % Area Int Area % Area 1 BG1st[UDF4] Unknown 18.0272318 92.6194949 2 Voigt Amp 1.49472135 1.43652346 7.38050513 Total 19.4637553 100.000000 ---- 我的程式是下面这样 已经把资料内容弄成string array 但是要输出想要资料的时候还是有问题 ex. 我想要输出有关peak 2的a0 a1 a2 a3及 Int Area 要输出哪个peak的资料 我是弄成由使用者来输入决定 因为要的资料不一定都是peak 2 有试过用StartWith 来判断想要的字串 写出来可以跑但输出档案太大开不起来 冏 所以我想我一定是有啥误会 就先把原本写的那些拿掉了 希望能有够进一步的指点 谢谢 textBox1是我的资料来源 textBox2是想要的peak textBox3是要输出的档案名称 ------ private void button1_Click(object sender, EventArgs e) { StreamReader reader = new StreamReader(textBox1.Text); string[] arrayStrings = reader.ReadToEnd().Split('\n'); string[] fi_num = arrayStrings[0].Split('\\'); string[] fi_num2 = fi_num[fi_num.Length - 1].Split('.'); FileInfo output = new FileInfo("D:\\0CSharp\\" + textBox3.Text + ".txt"); if (output.Exists) { StreamWriter txtwriter = output.AppendText(); txtwriter.WriteLine(fi_num2[0]); for (int i = 0; i != (arrayStrings.Length); i++) { string wantdata = textBox2.Text; string row = arrayStrings[i].TrimStart(); txtwriter.WriteLine(row); } txtwriter.Flush(); txtwriter.Close(); } else { StreamWriter txtwriter = output.CreateText(); txtwriter.WriteLine(fi_num2[0]); for (int i = 0; i != (arrayStrings.Length); i++) { string wantdata = textBox2.Text; string row = arrayStrings[i].TrimStart(); txtwriter.WriteLine(row); } txtwriter.Flush(); txtwriter.Close(); } } ---------- 再次感谢 各位能有耐心看完 --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.22.21
1F:→ soup514:善用debug 看看写的东西跟你想的有没有一致 03/21 20:46
2F:→ soup514:看资料fi_num fi_num2 都一样是a0a1那行 到底要split什麽 03/21 20:50
3F:→ ricaro:抱歉 那一行是资料的最开头有一行是档案来源 03/21 21:10
4F:→ ricaro:所以我用Split把档案的档名给截出来 因为那部份没问题 03/21 21:10
5F:→ ricaro:我就没有把原始资料的那部份也放上来了 抱歉 03/21 21:11
6F:→ soup514:栏位如果是固定长度就用substring去取出想要的数值啊 03/21 23:14
7F:→ ricaro:我目前没想到怎麽找到符合输入条件的字串 03/22 09:17
8F:→ ricaro:之前是先用Trim把空格除掉 再用startwith 03/22 09:17
9F:→ ricaro:不知道是不是语法有误 写出来可以跑 但输出档案太大 03/22 09:18
10F:→ ricaro:输出的结果开不起来 应该是我写的有问题 03/22 09:19
11F:→ ricaro:所以上来求助 03/22 09:25
12F:→ soup514:因为一直append吧 每次删掉 还是会档案太大? 03/22 20:29
13F:→ soup514:你这段程式 就只是把读进来的东西 又一行一行写出去而己 03/22 20:30
14F:→ ricaro:因为本来要用来判断所需资料的那部份有问题 所以删掉了 03/24 20:43
15F:→ ricaro:还是我把原本有问题的那部份也放上来? 03/24 20:44







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BabyMother站内搜寻

TOP