Private Sub Viewdoc(ByVal Idx As Integer) Kill_proses() System.Threading.Thread.Sleep(500) Dim objNewFileStream As FileStream = Nothing If My.Computer.FileSystem.DirectoryExists(temp) = True Then My.Computer.FileSystem.DeleteDirectory(temp, FileIO.DeleteDirectoryOption.DeleteAllContents) End If My.Computer.FileSystem.CreateDirectory(temp) Try Dim isigroup As DataTable objdata = New GlobalClass isigroup = objdata.QueryDatabase("select * from docu where id=" & id_docx) If isigroup.Rows.Count = 1 Then Dim nama_file As String = isigroup.Rows(0).Item(4).ToString isigroup = objdata.QueryDatabase("Select * from docs where docu_id =" & id_docx) Dim bytes() As Byte Dim imgStream As MemoryStream id_img = isigroup.Rows(0).Item(0) bytes = CType(isigroup.Rows(0).Item(2), Byte()) imgStream = New MemoryStream(bytes) imgStream.Position = 0 objNewFileStream = New FileStream(temp & "/" & nama_file, FileMode.OpenOrCreate, FileAccess.Write) Dim objBuffer(256) As Byte Dim intBytesRead As Integer = imgStream.Read(objBuffer, 0, 256) While intBytesRead > 0 objNewFileStream.Write(objBuffer, 0, intBytesRead) intBytesRead = imgStream.Read(objBuffer, 0, 256) End While If Not imgStream Is Nothing Then imgStream.Close() End If If Not objNewFileStream Is Nothing Then objNewFileStream.Close() wb.Focus() wb.Navigate(New Uri(temp & "\" & nama_file)) End If Catch ex As Exception MsgBox(ex.ToString) End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)