c# vs2003 我有个byte[]数组,如何存入文件?

c# vs2003 我有个byte[]数组,如何存入文件?,第1张

1、读取文件,并转换为字节流:

FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)

byte[] infbytes = new byte[(int)fs.Length]

fs.Read(infbytes, 0, infbytes.Length)

fs.Close()

return infbytes

2、将字节流写入文件

FileStream fs = new FileStream("D:\\inf.dlv", FileMode.Create, FileAccess.Write)

fs.Write(inf, 0, inf.Length)

fs.Close()

Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Public Sub WriteIniFileInfo(IniFileName As String, GroupTitle As String, Flags As String, SettingInfo As String)

WritePrivateProfileString GroupTitle, Flags, SettingInfo, IniFileName

End Sub

上面是准备工作,然后把下面这句填到你的那个地方去,是保存到当前目录下的run.ini文件中

Call WriteIniFileInfo(App.Path &"\run.ini", "运行参数", "usb_key_id", Str(usb_key_id))


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11787493.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存