Programming/VB

함수) VB에서 바이너리(이진파일) 읽고 쓰기

Calif 2017. 8. 16. 10:58

사용되는 네임스페이스(지만 함수 앞에 다 있ㅇㅁ...)

- System.IO

- System.Text


이진파일 생성과 쓰기(현재디렉토리)

Dim path As String = CurDir() & "\vs.bin"       

Dim fs As IO.FileStream = IO.File.Create(path)         

Dim MyString As String = "em.Text.Encoding.ASCII.GetBytes(MyString)

fs.WriteByte(barr)헤헤헤헿" 

Dim barr() As Byte = Syst


이진파일 생성과 동시에 쓰기

Dim path As String = CurDir() & "\vs.bin"       

             Dim MyString As String = "헤헤헤헿" 

             Dim barr() As Byte = System.Text.Encoding.ASCII.GetBytes(MyString)

             My.Computer.FileSystem.WriteAllBytes(path, barr, True)


이진파일 읽기

 Dim aarr() = My.Computer.FileSystem.ReadAllBytes(path)

 Dim abc As String = System.Text.Encoding.ASCII.GetString(aarr)


이진파일 존재 여부 확인

Dim path As String = CurDir() & "\vs.bin"       

if System.IO.Exist(path) then

'기타작업

else

'기타작업

end if 


기타 함수

- 파일 특성 설정 함수 SetAttr(파일경로, 특성) : 파일 숨김, 읽기 전용 등등 여러가지 설정 가능