20-09-23, 01:42 PM
لقد تم حل المشكلة بحول الله بمساعدة الذكاء الاصطناعي وهذا نص الكود ليستفيد منه من تواجهه نفس المشكلة:
كود :
. Imports System.Data.SqlClient
Imports System.IO
Public Class Doctec
Dim rdr As New SqlDataAdapter
Dim dt As New DataTable
Dim ofd As New OpenFileDialog()
Dim sfd As New SaveFileDialog
' ...
Private Sub cmbFiles_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbFiles.SelectedIndexChanged
Try
Dim FileName As String = Me.cmbFiles.Text
Dim Row As DataRow = dt.Rows.Find(Me.cmbFiles.SelectedValue)
Dim file_data() As Byte = CType(Row(2), Byte())
' طلب المسار الذي يريد المستخدم حفظ الملف فيه
sfd.Filter = "PDF Files (*.pdf)|*.pdf"
If sfd.ShowDialog() = DialogResult.OK Then
FileName = sfd.FileName ' استخدم المسار الذي اختاره المستخدم
Dim fs As New FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Write)
fs.Write(file_data, 0, file_data.Length)
fs.Close()
Process.Start(FileName)
End If
Catch ex As Exception
Exit Sub
End Try
End Sub
' ...
End Class 