VB.NET 读取1.txt,文本里面包含"UFO",然后删掉整个文档里包含UFO的文字,再保存 求代码
答案:2 悬赏:20 手机版
解决时间 2021-02-22 08:14
- 提问者网友:树红树绿
- 2021-02-21 13:45
VB.NET 读取1.txt,文本里面包含"UFO",然后删掉整个文档里包含UFO的文字,再保存 求代码
最佳答案
- 五星知识达人网友:洎扰庸人
- 2021-02-21 14:05
Dim MyStr As String
'读取一个文本文件
Dim MyReader As New System.IO.StreamReader(Application.StartupPath & "\MyText1.txt", System.Text.Encoding.Default)
MyStr = MyReader.ReadToEnd()
MyReader.Close()
'删除UFO
MyStr = Replace(MyStr, "UFO", "")
'写入一个文本文件
Dim MyStream As New System.IO.FileStream(Application.StartupPath & "\MyText1.txt", System.IO.FileMode.Create)
Dim MyWriter As New System.IO.StreamWriter(MyStream, System.Text.Encoding.Default)
MyWriter.WriteLine(MyStr)
MyWriter.Flush()
MyWriter.Close()
MyStream.Close()
'读取一个文本文件
Dim MyReader As New System.IO.StreamReader(Application.StartupPath & "\MyText1.txt", System.Text.Encoding.Default)
MyStr = MyReader.ReadToEnd()
MyReader.Close()
'删除UFO
MyStr = Replace(MyStr, "UFO", "")
'写入一个文本文件
Dim MyStream As New System.IO.FileStream(Application.StartupPath & "\MyText1.txt", System.IO.FileMode.Create)
Dim MyWriter As New System.IO.StreamWriter(MyStream, System.Text.Encoding.Default)
MyWriter.WriteLine(MyStr)
MyWriter.Flush()
MyWriter.Close()
MyStream.Close()
全部回答
- 1楼网友:渊鱼
- 2021-02-21 15:37
你好!
我可以帮你 发下测试文本
仅代表个人观点,不喜勿喷,谢谢。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯