通过VB.NET创建/编辑文本文件
发布时间:2020-12-17 00:19:30 所属栏目:大数据 来源:网络整理
导读:我如何在VB.NET中编写下面的算法? Procedure logfile(){ if "C:textfile.txt"=exist then open the textfile; else create the textfile; end if go to the end of the textfile; write new line in the textfile; save; close;} Dim FILE_NAME As String
我如何在VB.NET中编写下面的算法?
Procedure logfile() { if "C:textfile.txt"=exist then open the textfile; else create the textfile; end if go to the end of the textfile; write new line in the textfile; save; close; } Dim FILE_NAME As String = "C:textfile.txt" Dim i As Integer Dim aryText(4) As String aryText(0) = "Mary WriteLine" aryText(1) = "Had" aryText(2) = "Another" aryText(3) = "Little" aryText(4) = "One" Dim objWriter As New System.IO.StreamWriter(FILE_NAME,True) For i = 0 To 4 objWriter.WriteLine(aryText(i)) Next objWriter.Close() MsgBox("Text Appended to the File") 如果在System.IO.StreamWriter的构造函数中将第二个参数设置为True,则它将附加到文件(如果已存在),或者如果不存在则创建新文件. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |