Imports System.IO
Public Class Form1
Private FileName As String
Private Sub btnRead_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnRead.Click
Dim myStream As Stream = Nothing
Dim fd As New OpenFileDialog()
fd.InitialDirectory = "C:\Now"
fd.Filter = "PDF Files(*.pdf)|*.pdf"
fd.FilterIndex = 1
fd.RestoreDirectory = True
Try
If fd.ShowDialog() = DialogResult.OK Then
Process.Start(fd.FileName.ToString)
End If
FileName = Path.GetFileName(fd.FileName.ToString)
Catch Ex As Exception
MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
End Try
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
Dim fd As New SaveFileDialog()
fd.InitialDirectory = "C:\New"
fd.Filter = "PDF Files(*.pdf)|*.pdf"
fd.FilterIndex = 1
fd.FileName = FileName
Try
If fd.ShowDialog() = DialogResult.OK Then
File.Move(FileName, fd.FileName)
End If
Catch Ex As Exception
MessageBox.Show("Cannot save file to disk. Original error: " & Ex.Message)
End Try
End Sub
End Class