在vb.net中读取带有section和body的txt文件 [英] Read a txt file with section and body in vb.net
本文介绍了在vb.net中读取带有section和body的txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有这样的txt文件。
Hi
I have a txt file like this.
[BasicText]
Some text here in multiple lines...
Some text here in multiple lines...
Some text here in multiple lines...
[FooterText]
Some text here in multiple lines...
Some text here in multiple lines...
Some text here in multiple lines...
[Head]
Hide = 1
我如何读写这两节中的文字以及
我可以读写的内容Visual Basic中的hide选项.net
谢谢。
How I can read and write the text in these two sections and how
I can read and write the hide option in Visual Basic .net
Thank you.
推荐答案
以下是< a href =http://www.dotnetperls.com/file-readlines-vbnet>阅读文本文件 [ ^ ]
一旦你有数据查找部分标题。
或者看看这篇CP文章 INI读者/写作者类C#,VB.NET和VBScript [ ^ ]
Here is an example of reading text file[^]
Once you have the data look for the section headers.
Alternatively have a look at this CP article INI Reader / Writer Class for C#, VB.NET, and VBScript[^]
您好,您可以尝试 .NET库我为INI文件处理创建了。您可以使用VB.NET找到读取和写入部分和键的示例代码。
例如:
Hi, you can try .NET library I created for INI files processing. You can find sample codes for both reading and writing sections and keys with VB.NET.
For example:
Dim ini As New IniFile()
' Add new section.
ini.Sections.Add("Section's Name")
' Add new section with some keys.
Dim anotherSection = ini.Sections.Add("Another Section's Name")
anotherSection.Keys.Add("Key's Name", "Key's Value")
anotherSection.Keys.Add("Another Key's Name", "Another Key's Value")
我已经尝试过这篇文章
INI C#,VB.NET和VBScript的读/写器类 [ ^ ]
但是我必须插入部分和密钥而且它不起作用因为我必须插入部分和密钥但是大多数情况下我只有部分。在某些情况下,我有两个。
我必须说从另一个应用程序自动创建的文本文件,我不能为文件的格式做任何事情。
我只是想读写这个文件。
I have already try this article
INI Reader / Writer Class for C#, VB.NET, and VBScript[^]
but i have to insert section and key and it doesn't work cuz I must insert section and key but in most cases i have only sections. and in some cases I have both.
I have to say that the text file created automatically from another app and i can't do anything for the format of the file.
I just want to read and write this file.
这篇关于在vb.net中读取带有section和body的txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文