You are on page 1of 11

'Check before Save

Function CheckBeforeSave(ByVal xx As FrmAddfiles) As Boolean

If MyTextNull(xx.FileCode, "��� �����") Then Return True


If xx.FolderParent.SelectedNode Is Nothing Then
MessageBox.Show("�� ���� ���� ������ ���� �����", "����� �����",
MessageBoxButtons.OK, MessageBoxIcon.Information)
xx.FolderParent.Focus()
Return True
End If
If MyTextNull(xx.FileName, "��� �����") Then Return True
If MyCombIndexNull(xx.FileType, "��� �����") Then Return True
If xx.FileSecret.Checked = True And xx.FilePassword.Text.Trim =
String.Empty Then xx.FileSecret.Checked = False
Return False
End Function

'To Build AttachedFiles Table


Private Function BuildAttachedFilesTable(ByVal dgv As DataGridView, ByVal
SaveIn As Boolean) As DataTable

Dim dt As New DataTable


dt.Columns.Add("ParerntID")
dt.Columns.Add("FileName")
dt.Columns.Add("FileExtenssion")
dt.Columns.Add("FileSize")
dt.Columns.Add("FileData", Type.GetType("System.Byte[]"))
dt.Columns.Add("FileOrder")

For i As Int16 = 0 To dgv.Rows.Count - 1


If Val(dgv(0, i).Value) > 0 Then Continue For
If SaveIn = True Then
dt.Rows.Add(0, dgv(1, i).Value, dgv(2, i).Value, dgv(3, i).Value,
ReadFileData(dgv(5, i).Value), i + 1)
Else
dt.Rows.Add(0, dgv(1, i).Value, dgv(2, i).Value, dgv(3, i).Value,
Nothing, i + 1)
End If
Next
Return dt
dt.Dispose()
End Function

' Save Files Data


Public Sub Save_Files(ByVal xx As FrmAddfiles, ByVal SaveIn As Boolean)
Try
If CheckBeforeSave(xx) = True Then Return

Dim Cmd As SqlCommand


Cmd = New SqlCommand("InsertFiles", con)
Cmd.CommandType = CommandType.StoredProcedure

Dim Paramter(14) As SqlParameter

Paramter(0) = New SqlParameter("@FileCode", SqlDbType.Decimal, 28)


Paramter(0).Value = CDec(xx.FileCode.Text)

Paramter(1) = New SqlParameter("@FileName", SqlDbType.NVarChar, 300)


Paramter(1).Value = xx.FileName.Text
Paramter(2) = New SqlParameter("@FolderParent", SqlDbType.Decimal, 25)
Paramter(2).Value = CDec(xx.FolderParent.SelectedNode.Tag)

Paramter(3) = New SqlParameter("@RefrenceNum", SqlDbType.NVarChar)


Paramter(3).Value = xx.RefrenceNum.Text

Paramter(4) = New SqlParameter("@FileDescription", SqlDbType.NVarChar)


Paramter(4).Value = xx.FileDescription.Text

Paramter(5) = New SqlParameter("@FileExtenssion", SqlDbType.VarChar,


10)
Paramter(5).Value = xx.FileExtenssion.Text

Paramter(6) = New SqlParameter("@FileSize", SqlDbType.VarChar, 20)


Paramter(6).Value = xx.FileSize.Text

Paramter(7) = New SqlParameter("@FileType", SqlDbType.TinyInt)


Paramter(7).Value = CShort(xx.FileType.SelectedIndex)

Paramter(8) = New SqlParameter("@FileSecret", SqlDbType.Bit)


Paramter(8).Value = CBool(xx.FileSecret.Checked)

Paramter(9) = New SqlParameter("@FilePassword", SqlDbType.NVarChar, 25)


Paramter(9).Value = xx.FilePassword.Text

Paramter(10) = New SqlParameter("@AddUser", SqlDbType.TinyInt)


Paramter(10).Value = LogUserId

Paramter(11) = New SqlParameter("@DTAttaches", SqlDbType.Structured)


Paramter(11).Value = BuildAttachedFilesTable(xx.dgv, SaveIn)

Paramter(12) = New SqlParameter("@ID", SqlDbType.Int)


Paramter(12).Direction = ParameterDirection.Output

Paramter(13) = New SqlParameter("@SavedIn", SqlDbType.Bit)


Paramter(13).Value = SaveIn

Paramter(14) = New SqlParameter("@FilesData", SqlDbType.VarBinary)


If SaveIn = True Then Paramter(14).Value =
ReadFileData(xx.FileDescription.Tag.ToString) Else Paramter(14).Value = Nothing

Cmd.Parameters.AddRange(Paramter)
OpenConnection()
Cmd.ExecuteNonQuery()
CloseConnection()

If Paramter(12).Value > 0 Then


xx.ReturnID = Paramter(12).Value
If SaveIn = False Then xx.BackgroundWorker1.RunWorkerAsync()
ConfirmMessage(xx.lblconfirmMsg, xx.PicMsg, xx.Timer1, "�� �����
�����")
FrmMainPage.btnRefresh.PerformClick()
Threading.Thread.Sleep(1000)
xx.btnNew.PerformClick()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Erorr Message", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub

Public Sub CopySavedFile(ByVal xx As FrmAddfiles, ByVal FileID As String)


Try
Dim StoredPath As String
StoredPath = My.Settings.FilePath & "\Archived Files\" &
xx.FolderParent.SelectedNode.Tag.ToString
If My.Computer.FileSystem.FileExists(StoredPath) = False Then
Directory.CreateDirectory(StoredPath)

File.Copy(xx.FileDescription.Tag, StoredPath & "\" &


Path.GetFileName(xx.FileDescription.Tag))

If xx.dgv.Rows.Count > 0 Then


StoredPath = StoredPath & "\" & FileID
If My.Computer.FileSystem.FileExists(StoredPath) = False Then
Directory.CreateDirectory(StoredPath)

For i As Int16 = 0 To xx.dgv.Rows.Count - 1


File.Copy(xx.dgv(5, i).Value, StoredPath & "\" &
Path.GetFileName(xx.dgv(5, i).Value))
Next
End If

If xx.btnEdit.Enabled = True Then


File.Delete(xx.FileDescription.Tag)
For i As Int16 = 0 To xx.dgv.Rows.Count - 1
File.Delete(xx.dgv(5, i).Value)
Next
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Erorr Message", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub

Private Function ReadFileData(ByVal FilePath As String) As Byte()

Dim fileStream As New FileStream(FilePath, FileMode.Open, FileAccess.Read)


Dim Br As New BinaryReader(fileStream)
Dim FileData() As Byte = Br.ReadBytes(Br.BaseStream.Length)
Return FileData

End Function

'Show File Data


Public Sub Show_Data_Of_FileData(ByVal xx As FrmAddfiles, ByVal ID As Decimal)
Try
If ID > 0 Then
Dim DT, dt2 As New DataTable
Dim sqlst As String
sqlst = "Select * FROM FilesView where [FileCode] = " & ID & ""
FillDataTable(DT, sqlst)

If DT.Rows.Count > 0 Then


If xx.TabControl1.Enabled = False Then xx.btnNew.PerformClick()

xx.FileCode.Text = DT.Rows(0).Item("FileCode").ToString
GetParentNode(xx.FolderParent.Nodes,
CStr(DT.Rows(0).Item("FolderParent")), xx.FolderParent)
xx.FileName.Text = DT.Rows(0).Item("FileName").ToString
xx.RefrenceNum.Text = DT.Rows(0).Item("RefrenceNum").ToString
xx.FileDescription.Text =
DT.Rows(0).Item("FileDescription").ToString
xx.FileExtenssion.Text =
DT.Rows(0).Item("FileExtenssion").ToString
xx.FileSize.Text = DT.Rows(0).Item("FileSize").ToString
xx.FileSize.Tag = DT.Rows(0).Item("SavedIn")
xx.FileType.SelectedIndex = DT.Rows(0).Item("FileType")
xx.FileSecret.Checked = CBool(DT.Rows(0).Item("FileSecret"))
xx.FilePassword.Text = DT.Rows(0).Item("FilePassword").ToString
xx.FileId.Text = DT.Rows(0).Item("FileId").ToString
xx.AddUser.Text = DT.Rows(0).Item("AddUser").ToString
xx.AddDate.Text = DT.Rows(0).Item("AddDate").ToString
xx.EditUser.Text = DT.Rows(0).Item("EditUser").ToString
If IsDBNull(DT.Rows(0).Item("EditDate")) = False Then
xx.EditDate.Text = DT.Rows(0).Item("EditDate") Else xx.EditDate.Clear()

Dim StoredPath, FileStoredPath As String


StoredPath = My.Settings.FilePath & "Archived Files\"
FileStoredPath = StoredPath &
CStr(DT.Rows(0).Item("FolderParent")) & "\"
xx.RefrenceNum.Tag = FileStoredPath
Show_AttachedFiles(xx.dgv, CInt(DT.Rows(0).Item("FileId")),
CBool(DT.Rows(0).Item("SavedIn")), FileStoredPath)
xx.btnScan.Enabled = False
xx.btnbrows.Enabled = False
xx.btnSave.Enabled = False
xx.btnEdit.Enabled = True
xx.btnDelete.Enabled = True
xx.TSHeader.Text = "����� ������ �����"
If CBool(DT.Rows(0).Item("SavedIn")) = False Then
xx.FileDescription.Tag = FileStoredPath &
DT.Rows(0).Item("FileName") & DT.Rows(0).Item("FileExtenssion")
Else
dt2 =
GetInfo_OF_SelectedFileInArchivedTree(DT.Rows(0).Item("FileCode"), StoredPath)
xx.FileDescription.Tag = CreateSavedInFile(dt2)
End If
OpenFiles(xx, CStr(xx.FileDescription.Tag))
End If
DT.Dispose()
dt2.Dispose()
End If
Catch ex As Exception
Return
End Try
End Sub

Public Function CreateSavedInFile(ByVal dt As DataTable) As String


Dim FileData() As Byte = CType(dt.Rows(0).Item("FileData"), Byte())
Dim FileStream As New FileStream(dt.Rows(0).Item("FullName"),
FileMode.OpenOrCreate, FileAccess.Write)
FileStream.Write(FileData, 0, FileData.Length)
FileStream.Close()
Return dt.Rows(0).Item("FullName").ToString()
End Function
'Show Attached Files
Public Sub Show_AttachedFiles(ByVal dgv As DataGridView, ByVal ID As Int32,
ByVal IsSavedIn As Boolean, ByVal StoredPath As String)
Try
Dim DT As New DataTable
Dim SqlSt As String
SqlSt = "SELECT * From AttachedFiles where ParerntID =" & ID & ""
FillDataTable(DT, SqlSt)
dgv.Rows.Clear()
If DT.Rows.Count > 0 Then
For i As Int16 = 0 To DT.Rows.Count - 1
dgv.Rows.Add()
Dim last As Int16 = dgv.Rows.Count - 1
dgv(0, last).Value = DT.Rows(i).Item("ID")
dgv(1, last).Value = DT.Rows(i).Item("FileName")
dgv(2, last).Value = DT.Rows(i).Item("FileExtenssion")
dgv(3, last).Value = DT.Rows(i).Item("FileSize")
dgv(4, last).Value = DT.Rows(i).Item("AddDate")
If IsSavedIn = False Then
dgv(5, last).Value = StoredPath & ID & "\" &
DT.Rows(i).Item("FileName") & DT.Rows(i).Item("FileExtenssion")
Else
dgv(5, last).Value = Nothing
End If
dgv(8, last).Value = DT.Rows(i).Item("FileOrder")
Next
End If
DT.Dispose()
Catch ex As Exception
Return
End Try
End Sub

Public Function GetAttachedFile(ByVal ParerntID As Int32, ByVal FileOrder As


Short, ByVal FileName As String) As String
Try
Dim Paramter(1) As SqlParameter
Paramter(0) = New SqlParameter("@ParerntID", SqlDbType.Int)
Paramter(0).Value = ParerntID

Paramter(1) = New SqlParameter("@FileOrder", SqlDbType.TinyInt)


Paramter(1).Value = FileOrder

Dim dt As New DataTable


dt = GetDataTable("[GetSavedInAttachedFile]", Paramter)
Dim AttachedFolder, FullPath As String
AttachedFolder = My.Settings.FilePath & "Archived Files\Temp\
AttachedFile"
If My.Computer.FileSystem.FileExists(AttachedFolder) = False Then
IO.Directory.CreateDirectory(AttachedFolder)
FullPath = AttachedFolder & "\" & FileName
Dim FileData() As Byte = CType(dt.Rows(0).Item("AttachedFileData"),
Byte())
Dim FileStream As New FileStream(FullPath, FileMode.OpenOrCreate,
FileAccess.Write)
FileStream.Write(FileData, 0, FileData.Length)
FileStream.Close()
dt.Dispose()
Return FullPath
Catch ex As Exception
Return ""
End Try
End Function

' Update Files Data


Public Sub Upate_Files(ByVal xx As FrmAddfiles)
Try
If CheckBeforeSave(xx) = True Then Return

Dim Cmd As SqlCommand


Cmd = New SqlCommand("UpdateFiles", con)
Cmd.CommandType = CommandType.StoredProcedure

Dim Paramter(13) As SqlParameter

Paramter(0) = New SqlParameter("@FileCode", SqlDbType.Decimal, 28)


Paramter(0).Value = CDec(xx.FileCode.Text)

Paramter(1) = New SqlParameter("@FileName", SqlDbType.NVarChar, 300)


Paramter(1).Value = xx.FileName.Text

Paramter(2) = New SqlParameter("@FolderParent", SqlDbType.Decimal, 25)


Paramter(2).Value = CDec(xx.FolderParent.SelectedNode.Tag)

Paramter(3) = New SqlParameter("@RefrenceNum", SqlDbType.NVarChar)


Paramter(3).Value = xx.RefrenceNum.Text

Paramter(4) = New SqlParameter("@FileDescription", SqlDbType.NVarChar)


Paramter(4).Value = xx.FileDescription.Text

Paramter(5) = New SqlParameter("@FileType", SqlDbType.TinyInt)


Paramter(5).Value = CShort(xx.FileType.SelectedIndex)

Paramter(6) = New SqlParameter("@FileSecret", SqlDbType.Bit)


Paramter(6).Value = CBool(xx.FileSecret.Checked)

Paramter(7) = New SqlParameter("@FilePassword", SqlDbType.NVarChar, 25)


Paramter(7).Value = xx.FilePassword.Text.Trim

Paramter(8) = New SqlParameter("@EditUser", SqlDbType.TinyInt)


Paramter(8).Value = LogUserId

Paramter(9) = New SqlParameter("@DTAttaches", SqlDbType.Structured)


Paramter(9).Value = BuildAttachedFilesTable(xx.dgv,
CBool(xx.FileSize.Tag))

Paramter(10) = New SqlParameter("@SavedIn", SqlDbType.Bit)


Paramter(10).Value = CBool(xx.FileSize.Tag)

Paramter(11) = New SqlParameter("@FileId", SqlDbType.Int)


Paramter(11).Value = CInt(xx.FileId.Text)

Paramter(12) = New SqlParameter("@ID", SqlDbType.Decimal)


Paramter(12).Direction = ParameterDirection.Output

Paramter(13) = New SqlParameter("@ISChange", SqlDbType.TinyInt)


Paramter(13).Direction = ParameterDirection.Output
Cmd.Parameters.AddRange(Paramter)
OpenConnection()
Cmd.ExecuteNonQuery()
CloseConnection()

If Paramter(12).Value > 0 Then


xx.ReturnID = Paramter(11).Value.ToString
If Paramter(13).Value = 1 Then
xx.BackgroundWorker1.RunWorkerAsync()
ConfirmMessage(xx.lblconfirmMsg, xx.PicMsg, xx.Timer1, "�� �������
�����")
Threading.Thread.Sleep(1000)
FrmMainPage.btnRefresh.PerformClick()
Dim Xfind() As TreeNode =
FrmMainPage.TreeView1.Nodes.Find(Paramter(12).Value.ToString, True)
FrmMainPage.TreeView1.SelectedNode = Xfind(0)
xx.btnNew.PerformClick()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Erorr Message", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub

'Delete File From data Base


Public Function DeleteFileFromDataBase(ByVal FileID As Integer, ByVal SavePin
As Boolean) As Short

Dim Cmd As SqlCommand


Cmd = New SqlCommand("DeleteFile", con)
Cmd.CommandType = CommandType.StoredProcedure

Dim Paramter(2) As SqlParameter

Paramter(0) = New SqlParameter("@FileID", SqlDbType.Int)


Paramter(0).Value = FileID

Paramter(1) = New SqlParameter("@Savedin", SqlDbType.Bit)


Paramter(1).Value = SavePin

Paramter(2) = New SqlParameter("@ID", SqlDbType.TinyInt)


Paramter(2).Direction = ParameterDirection.Output

Cmd.Parameters.AddRange(Paramter)
OpenConnection()
Cmd.ExecuteNonQuery()
CloseConnection()
Return Paramter(2).Value

End Function

' To Find Search Item


Public Sub FindSearchedItem(ByVal dgv As DataGridView, ByVal Tv As TreeView,
ByVal TxT As TextBox)
Try
Dim xCode As String = dgv.CurrentRow.Cells("xCode").Value
dgv.DataSource = Nothing
dgv.Visible = False
Dim Xfind() As TreeNode = Tv.Nodes.Find(xCode, True)
Tv.SelectedNode = Xfind(0)
TxT.Clear()
TxT.Focus()
Catch ex As Exception
MessageBox.Show(ex.Message, "Erorr Message", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub

'Get Info OF Selected File in ArchiveTree


Public Function GetInfo_OF_SelectedFileInArchivedTree(ByVal FileCode As
Decimal, ByVal SavePath As String) As DataTable

Dim Paramter(1) As SqlParameter

Paramter(0) = New SqlParameter("@FileCode", SqlDbType.Decimal, 28)


Paramter(0).Value = FileCode

Paramter(1) = New SqlParameter("@SavePath", SqlDbType.NVarChar, 200)


Paramter(1).Value = SavePath

Dim dt As New DataTable


dt = GetDataTable("[OpenSelectedFile]", Paramter)
Return dt
dt.Dispose()
End Function

Public Sub CheckIFSelectedFileSecret(ByVal xx As FrmMainPage)


Try
Dim dt As New DataTable
dt =
GetInfo_OF_SelectedFileInArchivedTree(CDec(xx.TreeView1.SelectedNode.Tag),
My.Settings.FilePath & "Archived Files\")
If dt.Rows(0).Item("isFileSecret") = True Then
Dim zz As New FrmPassword
zz.ShowDialog()
If zz.InputText = Nothing Then Return
If zz.InputText = dt.Rows(0).Item("FilePasword") Then
OpenSelectedFileInArchivedTree(xx, dt)
Else
MessageBox.Show("������ ���� ������ ���� ������� ��� �����",
"����� �����", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Else
OpenSelectedFileInArchivedTree(xx, dt)
End If
dt.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message, "Erorr Message", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub

'Open Selected File in ArchiveTree


Public Sub OpenSelectedFileInArchivedTree(ByVal xx As FrmMainPage, ByVal dt As
DataTable)
Try
If dt.Rows(0).Item("xx") = 0 Then
xx.WebBrowser1.Url = New Uri(dt.Rows(0).Item("FileFullPath"))
'xx.AxAcroPDF1.src = dt.Rows(0).Item("FileFullPath")
Else
Dim FileData() As Byte = CType(dt.Rows(0).Item("FileData"), Byte())
Dim FileStream As New FileStream(dt.Rows(0).Item("FullName"),
FileMode.OpenOrCreate, FileAccess.Write)
FileStream.Write(FileData, 0, FileData.Length)
FileStream.Close()

xx.WebBrowser1.Url = New Uri(dt.Rows(0).Item("FullName"))


'xx.AxAcroPDF1.src = dt.Rows(0).Item("FullName")
End If
Catch ex As Exception
Return
End Try
End Sub

Public Sub CreateTempFolder()


Dim StoredPath As String = My.Settings.FilePath & "Archived Files\Temp"
If My.Computer.FileSystem.FileExists(StoredPath) = False Then
IO.Directory.CreateDirectory(StoredPath)
End Sub

Public Sub GetCopyOfFile(ByVal xx As FrmMainPage)


Try
If MessageBox.Show("�� ��� ��� ���� �� ��� " &
xx.TreeView1.SelectedNode.Text & "�", "����� �����", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) = DialogResult.No Then Return
Dim dt As New DataTable
dt =
GetInfo_OF_SelectedFileInArchivedTree(CDec(xx.TreeView1.SelectedNode.Tag),
My.Settings.FilePath & "Archived Files\")
If dt.Rows.Count > 0 Then
Dim FilePath, Newpath As String
Dim fbd As New FolderBrowserDialog

If dt.Rows(0).Item("xx") = 0 Then
FilePath = dt.Rows(0).Item("FileFullPath")
Else
Dim FileData() As Byte = CType(dt.Rows(0).Item("FileData"),
Byte())
Dim FileStream As New FileStream(dt.Rows(0).Item("FullName"),
FileMode.OpenOrCreate, FileAccess.Write)
FileStream.Write(FileData, 0, FileData.Length)
FileStream.Close()
FilePath = dt.Rows(0).Item("FullName")
End If

If MessageBox.Show("... �� ���� ���� ������ ������ ��� ����� ��� ",


"����� �����", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) =
DialogResult.Cancel Then Return
If fbd.ShowDialog = DialogResult.OK Then
Newpath = fbd.SelectedPath & "\" &
My.Computer.FileSystem.GetName(FilePath)

If My.Computer.FileSystem.FileExists(Newpath) = True Then


If MessageBox.Show("�� ��� " &
xx.TreeView1.SelectedNode.Text & vbNewLine &
" ����� ����� .. �� ��� ��� ����� ����
���� � ", "����� �����", MessageBoxButtons.YesNo, MessageBoxIcon.Question) =
DialogResult.No Then Return
Dim NewName As String
NewName = InputBox("���� ����� ������ �����", "�����")
Newpath = fbd.SelectedPath & "\" & NewName &
Path.GetExtension(FilePath)
End If
File.Copy(FilePath, Newpath)
MessageBox.Show("��� ����� ��� ����� �����", "����� �����",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Erorr Message", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub

Public Sub CheckIFSelectedFileSecretBeforeSend(ByVal xx As FrmMainPage)


Try
Dim dt As New DataTable
dt =
GetInfo_OF_SelectedFileInArchivedTree(CDec(xx.TreeView1.SelectedNode.Tag),
My.Settings.FilePath & "Archived Files\")
If dt.Rows(0).Item("isFileSecret") = True Then
Dim zz As New FrmPassword
zz.ShowDialog()
If zz.InputText = Nothing Then Return
If zz.InputText = dt.Rows(0).Item("FilePasword") Then
SendFilePathToFrmEmail(xx, dt)
Else
MessageBox.Show("������ ���� ������ ���� ������� ��� �����",
"����� �����", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Else
SendFilePathToFrmEmail(xx, dt)
End If
dt.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message, "Erorr Message", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub

'Send File Path To FrmEmail


Public Sub SendFilePathToFrmEmail(ByVal xx As FrmMainPage, ByVal dt As
DataTable)
Try
If dt.Rows(0).Item("xx") = 0 Then
Dim Frm As New FrmEMail
Frm.AttachPath = dt.Rows(0).Item("FileFullPath")
Frm.Show(xx)
Else

Dim FileData() As Byte = CType(dt.Rows(0).Item("FileData"), Byte())


Dim FileStream As New FileStream(dt.Rows(0).Item("FullName"),
FileMode.OpenOrCreate, FileAccess.Write)
FileStream.Write(FileData, 0, FileData.Length)
FileStream.Close()

Dim Frm As New FrmEMail


Frm.AttachPath = dt.Rows(0).Item("FullName")
Frm.Show(xx)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Erorr Message", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub

You might also like