Zooflow: frmtest streams

This commit is contained in:
Jonathan Jenne 2021-03-16 11:38:07 +01:00
parent 635d5f5f94
commit 099d65ed70

View File

@ -20,33 +20,34 @@ Public Class frmtest
Private Async Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Try
Dim oResult As Boolean
Dim oStream As New FileStream(txtFile2Import.Text, FileMode.Open)
Dim oContents(oStream.Length) As Byte
'Dim oBytesRead = Await oStream.ReadAsync(oContents, 0, oStream.Length)
Dim oResult As Boolean = False
Using oStream As New FileStream(txtFile2Import.Text, FileMode.Open, FileAccess.Read)
Dim oContents(oStream.Length) As Byte
oStream.Read(oContents, 0, oStream.Length)
oResult = Await _Client.ImportIDBFOAsync(oContents, My.Application.User.UserName, txtIDB_OBJ_ID.Text, 1, txtIDBFOPath.Text)
End Using
oResult = Await _Client.ImportIDBFOAsync(oContents, My.Application.User.UserName, txtIDB_OBJ_ID.Text, 1, txtIDBFOPath.Text)
If oResult = False Then
MsgBox("Oh no error", MsgBoxStyle.Critical)
Else
MsgBox("#Nailedit")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim memString As String = "Memory test string !!!"
Dim buffer As Byte() = Encoding.UTF8.GetBytes(memString)
' convert string to stream
Dim buffer As Byte() = Encoding.ASCII.GetBytes(memString)
Dim ms As New MemoryStream(buffer)
'write to file
Dim file As New FileStream("d:\file.txt", FileMode.Create, FileAccess.Write)
ms.WriteTo(file)
file.Close()
ms.Close()
Using oMemoryStream As New MemoryStream(buffer)
Using oFileStream As New FileStream("d:\file.txt", FileMode.Create, FileAccess.Write)
oMemoryStream.WriteTo(oFileStream)
End Using
End Using
End Sub
End Class