标题:为啥StreamWriter写入txt失败
取消只看楼主
cady_s
Rank: 1
来 自:天津
等 级:新手上路
帖 子:21
专家分:0
注 册:2009-10-31
结帖率:50%
已结贴  问题点数:10 回复次数:0 
为啥StreamWriter写入txt失败
这是我编的一个小程序,是要读取data.txt中开头是0的行,然后写进out.txt中,可是程序运行后,out.txt中是空的,求教是哪里错了呢?谢谢!
using System;
using System.Collections.Generic;
using System.Text;
using

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamReader data = new StreamReader("E:\\data.txt");
            string Line1 = "";

            StreamWriter radardata = new StreamWriter("E:\\out.txt", false);
            radardata.Write("译码:");

            while (Line1 != null)
            {
                Line1 = data.ReadLine();
                char[] chars = Line1.ToCharArray();
                if (chars[0] != '0')
                    continue;
                else
                {
                    string[] sArray = Line1.Split(' ');
                    foreach (string i in sArray)
                        radardata.Write(i);

                }

            }
            radardata.Close();
        }
    }
}
搜索更多相关主题的帖子: txt 失败 StreamWriter 
2009-12-17 22:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-293804-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.745043 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved