小编tvo*_*tko的帖子

StreamWriter无法在C#中工作

这段代码在VS 2010中完美运行.现在我已经拥有了VS 2013,它不再写入该文件.它没有错误或任何东西.(我在Notepad ++中收到警告,说明文件已更新,但没有写入.)

这对我来说都很好看.有任何想法吗?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            String line;
            try
            {
                //Pass the file path and file name to the StreamReader constructor
                StreamReader sr = new StreamReader("C:\\Temp1\\test1.txt");
                StreamWriter sw = new StreamWriter("C:\\Temp2\\test2.txt");

                //Read the first line of text
                line = sr.ReadLine();

                //Continue to read until you reach end of file
                while (line != null)
                {
                    //write the line to console window …
Run Code Online (Sandbox Code Playgroud)

c# streamwriter streamreader

6
推荐指数
2
解决办法
777
查看次数

标签 统计

c# ×1

streamreader ×1

streamwriter ×1