문제

파일에서 원시 바이트 배열을 어떻게 읽습니까 ...

 Dim bytes() as Byte

.. 그런 다음 바이트 배열을 새 파일에 다시 작성합니까?

사이에 처리를 수행하려면 바이트 배열로 필요합니다.


나는 현재 사용하고있다 :

읽다

 Dim fInfo As New FileInfo(dataPath)
 Dim numBytes As Long = fInfo.Length
 Dim fsAs New FileStream(dataPath, FileMode.Open, FileAccess.Read)
 Dim br As New BinaryReader(fs)
 Dim bytes As Byte() = br.ReadBytes(CInt(numBytes))
 br.Close()
 fs.Close()

쓰기

Dim fs As System.IO.FileStream
fs = New System.IO.FileStream(outpath, System.IO.FileMode.Create)
fs.Write(bytes, 0, bytes.Length)
fs.Close()
도움이 되었습니까?

해결책

Dim data() as Byte = File.ReadAllBytes(path1)
File.WriteAllBytes(path2, data)

다른 팁

System.IO.File.ReadAllBytes("myfile.txt")

이 시도:-

Dim bytes() as Byte
bytes = File.ReadAllBytes(fileName)
'' # Do stuff to the array
File.WriteAllBytes(otherFileName, bytes)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top