且构网

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

写入文本文件

更新时间:2021-10-20 22:14:21

你好Mike


MSDN上的内容比你想象的要多

http://msdn.microsoft.com/library/de...gToLogFile.asp

我希望这有帮助吗?


Cor
Hi Mike

There is more on MSDN than you think

http://msdn.microsoft.com/library/de...gToLogFile.asp

I hope this helps?

Cor


*" Mike" <一个******* @ discussions.microsoft.com> scripsit:
* "Mike" <an*******@discussions.microsoft.com> scripsit:
我有一个文本文件,我需要一次写入多行数据。
我怎么能写一行以上的数据到文件?
I have a text file that i need to write multiple lines of data to but one at
a time.
how can i write more then one line of data to the file?




查看''System.IO.StreamWriter'及其''WriteLine''方法。


-

Herfried K. Wagner [MVP]

< URL:http://dotnet.mvps.org/>



Have a look at ''System.IO.StreamWriter'' and its ''WriteLine'' method.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


我认为你的问题是你需要打开附加标志

设置为True的文件,这样每次都不会覆盖文件:


Dim IOFile as IO.StreamWriter(" LogFile.txt",True)

....

IOFile.WriteLine(txtToWrite)

IOFile.Close


希望有所帮助,


-

Marc Butenko
mb******@bresnan.net


&QUOT;麦克&QUOT; &LT;一个******* @ discussions.microsoft.com&GT;在留言中写道

新闻:ON ************** @ TK2MSFTNGP11.phx.gbl ...
I think your problem is that you need to open the file with the Append flag
set to True so the file is not overwritten everytime:

Dim IOFile as IO.StreamWriter("LogFile.txt", True)
....
IOFile.WriteLine(txtToWrite)
IOFile.Close

Hope that helps,

--
Marc Butenko
mb******@bresnan.net

"Mike" <an*******@discussions.microsoft.com> wrote in message
news:ON**************@TK2MSFTNGP11.phx.gbl...
我有一个文本文件我需要一次写一行
来写多行数据。
我怎样才能在文件中写入多行数据呢?

示例:
服务器上没有文件我将其写入文本文件。
然后我搜索另一个文件,如果不存在,再次写入
文本文件。

我需要使用相同的文本文件,并将所有不存在的文件
添加到文件中,而不会丢失任何文件。
我怎么能这样做?
I have a text file that i need to write multiple lines of data to but one at a time.
how can i write more then one line of data to the file?

example:
i do a search for a file on a server if the file does not exist on the
server i write it to text file.
then i search for another file and if that does not exist, again write to
the text file.

I need to use the same text file and add all the files that do not exist to the file without loosing any.
how can i do that?