c# 操作txt

jackwolf2014 2014-07-03 11:17:38
c# 操作txt:
根据txt中的数据,利用zedGraph或其他控件绘制折线图,不知道有没有高手做过相关的
...全文
282 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mxl_2582294052 2014-07-05
  • 打赏
  • 举报
回复
读取文本文件中的数据行 private void button1_Click(object sender, EventArgs e) { try { openFileDialog1.Filter = "文本文件(*.txt)|*.txt"; openFileDialog1.ShowDialog(); textBox1.Text = openFileDialog1.FileName; StreamReader SReader = new StreamReader(textBox1.Text, Encoding.Default); string strLine = string.Empty; while ((strLine = SReader.ReadLine()) != null) { textBox2.Text += strLine + Environment.NewLine; } } catch { } }
wuyq11 2014-07-05
  • 打赏
  • 举报
回复
zedGraph,mschartd都可 <asp:Chart ID="Chart1" runat="server" Height="434px" Width="793px" BorderlineDashStyle="Solid" BorderlineColor="Gray" BackGradientStyle="DiagonalLeft" BackSecondaryColor="AliceBlue" BackColor="WhiteSmoke"> <Titles> <asp:Title Font="微软雅黑, 16pt" Name="Title1" Text="增加方式统计"> </asp:Title> </Titles> <Legends> <asp:Legend Name="Legend1" Alignment="Near"> </asp:Legend> </Legends> <Series> <asp:Series Name="Series1" ChartType="Pie" Font="Arial" IsValueShownAsLabel="True" Label="#VALX:#VAL"> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1"> </asp:ChartArea> </ChartAreas> </asp:Chart> List<DeputyStatis> lstatis = (from c in list group c by new { c.AddMode } into g orderby g.Key.AddMode select new DStatis { Name = g.Key.AddMode + "(人数:" + g.Count() + "人)", Count = g.Count(), } ).ToList(); FIle.readalllines,writeallines都是常用操作
threenewbee 2014-07-04
  • 打赏
  • 举报
回复
引用 2 楼 mlxwl2013 的回复:
[quote=引用 1 楼 caozhy 的回复:] 比如txt的内容是 1 2 3 那么你可以这么加载: int[] data = File.ReadAllLines("1.txt").Select(x => (int)x).ToArray(); 下面就可以绑定了。
上面写的这个有误,更正一下: int[] data = File.ReadAllLines("1.txt").Select(x => int.Parse(x)).ToArray();[/quote] 谢谢更正。
熙风 2014-07-04
  • 打赏
  • 举报
回复
mlxwl2013 2014-07-04
  • 打赏
  • 举报
回复
引用 1 楼 caozhy 的回复:
比如txt的内容是 1 2 3 那么你可以这么加载: int[] data = File.ReadAllLines("1.txt").Select(x => (int)x).ToArray(); 下面就可以绑定了。
上面写的这个有误,更正一下: int[] data = File.ReadAllLines("1.txt").Select(x => int.Parse(x)).ToArray();
threenewbee 2014-07-03
  • 打赏
  • 举报
回复
比如txt的内容是 1 2 3 那么你可以这么加载: int[] data = File.ReadAllLines("1.txt").Select(x => (int)x).ToArray(); 下面就可以绑定了。

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧