VB.Net Basic Reading And Writing
Imports System.IO
' Drag and Drop OpenFileDialog1 onto your form.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
OpenFileDialog1.ShowDialog
End Sub
' Go to Designer and click the OpenFileDialog1 on the bottom.
' Go to the settings on the right.
' you will see a lightning bolt.
End Class
' Click on the lightning bolt.
' Double Click on 'FileOk'
you will see a code snippet like this.
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
' Type this,
If File.Exist(OpenFileDialog1.FileName) Then
Dim ByteArray() As Byte = File.ReadAllBytes(OpenFileDialog1.FileName)
' Now we have the file in Bytes. Best Way to open it.
' Lest Save this File in a Different Location.
File.WriteAllBytes(InputBox("File Name"), ByteArray)
Else
MsgBox("File Does Not Exit")
End If
End Sub
' Simple use File. to get Files.
' or Directory. to get Folders.
No comments:
Post a Comment