且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在C#中创建文本文件?

更新时间:2023-01-23 10:46:37

将文本写入文件

系统。 IO.File.WriteAllText

方法并将文本附加到现有文件

System.IO.File.AppendAllText

方法可以使用



这里给出一个例子

http://msdn.microsoft.com/en-us/library/ms143375.aspx [ ^ ]

这个可能对你有所帮助。
To write text to file
System.IO.File.WriteAllText
method and to append text to the existing file
System.IO.File.AppendAllText
method can be used

An example is given here
http://msdn.microsoft.com/en-us/library/ms143375.aspx[^]
This may be helpful to you.


对不起谷歌已经坏了。 File.Create [ ^ ]
I'm sorry Google is broken. File.Create[^]


如果您只需要使用文件类,这就是您的解决方案,



If you need only use file class, this is the solution for you,

File.WriteAllText("D:\\as.txt", "welcome");