Public Class Form1の全コード
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'OpenFileDialogを開く
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
'変数srをSystem.IO.StreamReader型で生成
Dim sr As System.IO.StreamReader = My.Computer.FileSystem.OpenTextFileReader(OpenFileDialog1.FileName)
'変数FirstLineをString型で生成
Dim FirstLine As String = sr.ReadLine() & vbCrLf & sr.ReadLine()
'変数FirstLineを表示|
MsgBox(FirstLine)
'変数readerをString型で生成
Dim reader As String = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
'SaveFileDialogを開く
If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
'readerの内容をファイル出力
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, reader, append:=False)
End If
End If
End Sub
End Class