试图写入.txt文件 [英] Trying to write into a .txt file

查看:95
本文介绍了试图写入.txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个写入.txt文件的简单程序。该文件与程序的.exe文件位于同一文件夹中。

I'm trying to make a simple program that writes into a .txt file. The file is in the same folder as the program's .exe file.

没有错误,程序运行。然而文本文件仍然是空的......

No errors, program runs through. Yet the text file remains empty...

我仍处于初学者水平,所以请尽量保持简单:)

I'm still at the beginner level with this so keep it as simple as possible :)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (System.IO.StreamWriter file = new System.IO.StreamWriter("T1TextLines.txt"))
            {
                string input = "Can you see me?";
                file.WriteLine(input);
                file.Close();
            }

             Console.WriteLine("Passed?");
        }
    }
}




推荐答案


我正在尝试创建一个写入.txt文件的简单程序。该文件与程序的.exe文件位于同一文件夹中。

I'm trying to make a simple program that writes into a .txt file. The file is in the same folder as the program's .exe file.

没有错误,程序运行。然而,文本文件仍为空...

No errors, program runs through. Yet the text file remains empty...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (System.IO.StreamWriter file = new System.IO.StreamWriter("T1TextLines.txt"))
            {
                string input = "Can you see me?";
                file.WriteLine(input);
                file.Close();
            }

             Console.WriteLine("Passed?");
        }
    }
}





您使用的是哪个版本的Visual Studio?



您确定要查找正确的目录吗?

向我们展示完整的路径。 (编辑个人姓名,如果这是一个问题。)



程序应该创建包含字符串的文本文件。



- Wayne

Which version of Visual Studio are you using?

Are you sure you're looking in the right directory?
Show us the full path. (Edit out personal name, if that's an issue.)

The program should create the text file with the string in it.

- Wayne


这篇关于试图写入.txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆