| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1073 人关注过本帖
标题:为啥StreamWriter写入txt失败
只看楼主 加入收藏
cady_s
Rank: 1
来 自:天津
等 级:新手上路
帖 子:21
专家分:0
注 册:2009-10-31
结帖率:50%
收藏
已结贴  问题点数:10 回复次数:1 
为啥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
gameohyes
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:53
帖 子:1275
专家分:3629
注 册:2009-3-5
收藏
得分:10 

 StreamReader data = new StreamReader("c:\\1.txt");
            string Line1 = "";

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

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

                }

            }
            radardata.Close();

C#超级群 74862681,欢迎大家的到来!
2009-12-18 00:09
快速回复:为啥StreamWriter写入txt失败
数据加载中...
 
   



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

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