VB.net讀寫位元據方法

來源:互聯網
上載者:User

一、二進位檔案讀寫

1、寫位元據到指定目錄

 dim barray() as byte dim strFileName as string My.Computer.FileSystem.WriteAllBytes(strFileName, barray, False)

 ==>將barray位元組數組中的資料建立在strFilename目錄檔案下,儲存格式為二進位,False表示不添加,直接覆蓋建立。


2、從指定路徑下讀取位元據到數組

 dim barray() as byte dim strFileName as string barray=My.Computer.FileSystem.ReadAllBytes(cmbSendFilePath.Text)

 ==>將目錄中的檔案讀取到barry位元組數組中,即讀取二進位檔案。


二、字元檔案的讀寫


1、 將txtFile控制項中的字元寫到srtFileName指定目錄,以建立方式

    Imports System.IO     //Class之前置入        dim strFileName as string     dim objwriter As steamWriter = new steamWriter(strFileName,Flase)    objwriter.write(txtFile.text)    objwriter.close()     //關閉    objwriter=nothing     //釋放資源

2、從srtFileName目錄中的檔案讀取到txtFile控制項

    Imports System.IO          //Class之前置入        dim strFileName as string     dim objreader as streamReader = new steamReader(strFileName)    txtFile.text = objreader.readtoend()    objreader.close()    //關閉    objReader=Nothing    /釋放資源

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.