diff --git a/GUIs.ZooFlow/frmtest.vb b/GUIs.ZooFlow/frmtest.vb index a693dd87..aaf6586e 100644 --- a/GUIs.ZooFlow/frmtest.vb +++ b/GUIs.ZooFlow/frmtest.vb @@ -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 \ No newline at end of file