[VB.NET]请教:VB.NET中文件写入问题!!

VB.NET源码-156个实用实例哦…… <script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
请教:VB.NET中文件写入问题!!
本人刚接触.NET 遇到这样一个问题: 要把一段文字(STRING)写入到指定文件中,不知道用何方法,请熟悉这方面的朋友指点一下.具体判断是 如果在指定路径下 没有该文件名,则在该路径下创建文件. 并将上面文字写入文件中 保存.
请高手帮忙 不胜感激!!
__________________________________________________________________________
Imports System.IO
Imports System.Text

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim s As String
Dim bte As Byte()
Dim myfile As New FileStream( d:/123.txt , FileMode.Create, FileAccess.Write)

s = 要保存到文件的文字
bte = Encoding.Default.GetBytes(s)

myfile.Write(bte, 0, bte.Length)
myfile.Close()

End Sub
End Class
__________________________________________________________________________
Dim chl As New System.IO.StreamWriter( 路径,比如c:/123.txt , True)
chl.WriteLine( 要写入的字符串 )
chl.Close()
__________________________________________________________________________
Dim chl As New System.IO.StreamWriter( 路径,比如c:/123.txt , True)
chl.WriteLine( 要写入的字符串 )
chl.Close()
__________________________________________________________________________
没看到还要创建文件,补充

If Not File.Exists( 路径,比如c:/123 ) Then
File.Create( 路径,比如c:/123 ).Close()
End If
Dim chl As New System.IO.StreamWriter( 路径,比如c:/123.txt , True)
chl.WriteLine( 要写入的字符串 )
chl.Close()
__________________________________________________________________________
FileOpen(1, c:/new.txt , OpenMode.Append)
PrintLine(1, 寫入第一行 )
Print(1, 寫入第二行 )
Print(1, 接在第二行後寫入 寫入第三行 )
FileClose(1)
__________________________________________________________________________
也可以用MY命名空间
__________________________________________________________________________
my.computer.filsystem.writealltext(路径,要写入的文件内容,是覆盖还是追加)
__________________________________________________________________________
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值