StreamWriter.Write不写入文件;没有抛出异常 [英] StreamWriter.Write doesn't write to file; no exception thrown

查看:137
本文介绍了StreamWriter.Write不写入文件;没有抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code在C#(asp.net MVC)

My code in C# (asp.net MVC)

StreamWriter tw = new StreamWriter("C:\\mycode\\myapp\\logs\\log.txt");

// write a line of text to the file
tw.Write("test");

创建的文件,但为空。无异常。我从来没有见过这一点,我在这里停留;我只需要编写一些调试输出。

The file is created but is empty. No exception is thrown. I have never seen this before and I am stuck here; I just need to write some debugging output.

请指教。

推荐答案

使用

System.IO.File.WriteAllText(@"path\te.txt", "text");

这篇关于StreamWriter.Write不写入文件;没有抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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