Create a zip File From a Single file - vb.net

Create a zip File From a Single file.
I have start to build a new compression tool on vb.net and its works fine, but i have to make a directory first and insert my files into it and then compress.
How can i make a compress file from a single file by press the button5.
I have try like this
ZipFileExtensions.CreateEntryFromFile(TextBox4.Text, TextBox3.Text, CompressionLevel.Optimal)
the textbox4 is the chose file and textbox3 is name for the file
but it give me the error The value of type cannot be converted to System.IO.Compression.ZipArchive
This is my code
Imports System.IO
Imports System.IO.Compression
Public Class Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ProgressBar1.Show()
Timer1.Start()
TextBox2.Text = TextBox2.Text + "\" + TextBox3.Text
' Create ZIP from "source" directory (in program folder).
ZipFile.CreateFromDirectory(TextBox1.Text,
TextBox2.Text + ".zip",
CompressionLevel.Optimal,
False)
MessageBox.Show("The Process are complete", "MediaZip", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ProgressBar1.Hide()
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub ProgressBar1_Click(sender As Object, e As EventArgs) Handles ProgressBar1.Click
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim dialog As New FolderBrowserDialog()
dialog.RootFolder = Environment.SpecialFolder.Desktop
dialog.SelectedPath = "C:\"
dialog.Description = "Select Application Configuration Files Path"
If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
TextBox1.Text = dialog.SelectedPath
End If
TextBox1.Text = dialog.SelectedPath
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim dialog As New FolderBrowserDialog()
dialog.RootFolder = Environment.SpecialFolder.Desktop
dialog.SelectedPath = "C:\"
dialog.Description = "Select A Folder To Compress"
If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
TextBox2.Text = dialog.SelectedPath
End If
TextBox2.Text = dialog.SelectedPath
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(1 * 55)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim OpenFileDialog1 As New OpenFileDialog
OpenFileDialog1.InitialDirectory = "C:\"
OpenFileDialog1.FileName = "Select A File..."
OpenFileDialog1.Multiselect = False
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim sName As String = OpenFileDialog1.SafeFileName
TextBox4.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
End Sub
End Class

I have finally sort all the the errors and its working like i want.
I make a temporary directory, move the chosen file into it, then compress and send it to the Desktop , and finally delete the temporary directory.
This is the working code
Imports System.IO
Imports System.IO.Compression
Imports System
Imports System.Windows.Forms
Imports System.Net
Imports System.Diagnostics
Public Class Form4
Dim tempdir As String = "C:\MediaZip"
Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Form1.Hide()
Me.BringToFront()
IO.Directory.Delete(tempdir, True)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ProgressBar1.Show()
Timer1.Start()
TextBox2.Text = TextBox2.Text + "\" + TextBox3.Text
' Create ZIP from "source" directory (in program folder).
ZipFile.CreateFromDirectory("C:\MediaZip",
TextBox2.Text + ".zip",
CompressionLevel.Optimal,
False)
MessageBox.Show("The Process are complete", "MediaZip", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ProgressBar1.Hide()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim dialog As New FolderBrowserDialog()
dialog.RootFolder = Environment.SpecialFolder.Desktop
dialog.SelectedPath = "C:\"
dialog.Description = "Were To Store Your File ?"
If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
TextBox2.Text = dialog.SelectedPath
End If
TextBox2.Text = dialog.SelectedPath
Dim logDirectoryProperties As System.IO.DirectoryInfo
My.Computer.FileSystem.CopyFile(
TextBox1.Text,
"C:\MediaZip\" + TextBox4.Text)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim OpenFileDialog1 As New OpenFileDialog
OpenFileDialog1.InitialDirectory = "C:\"
OpenFileDialog1.FileName = "File To Zip..."
OpenFileDialog1.Multiselect = True
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim sName As String = OpenFileDialog1.SafeFileName
TextBox1.Text = OpenFileDialog1.FileName
TextBox4.Text = System.IO.Path.GetFileName(OpenFileDialog1.FileName)
IO.Directory.Delete(tempdir, True)
End If
End Sub
End Class

Related

Why openFileDialog doesn't responding when i dispose the form and back to it again?

I have tow openFileDialog tools in one form, when i browse openFileDialog1 and choose a picture, it's ok but when i dispose this form and back to it and click to browse another picture, it doesn't responding and the project stopped with no errors!!!
Private Sub Browse_Click(sender As Object, e As EventArgs) Handles Browse.Click
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "Image Files (*.jpg, *.bmp, *.gif, *.png)|*.jpg; *.bmp; *.gif; *.png"
If OpenFileDialog1.FileName = "" Then
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
txtFileName.Text = OpenFileDialog1.FileName
txtFileName.SelectionStart = txtFileName.Text.Length 'to show the last portion of text
If Trim(txtFileName.Text) <> "" Then picSave.Image = Image.FromFile(txtFileName.Text)
End If
Else
Exit Sub
End If
End Sub
Private Sub Btnclose_Click(sender As Object, e As EventArgs) Handles Btnclose.Click
Me.Dispose()
End Sub
In Project Properties be sure you have set Shutdown Mode to "When last form closes." This is NOT the default.
In Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
OpenFileDialog1.Filter = "Image Files (*.jpg, *.bmp, *.gif, *.png)|*.jpg; *.bmp; *.gif; *.png"
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
TextBox1.Text = OpenFileDialog1.FileName
PictureBox1.Image = Image.FromFile(TextBox1.Text)
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form2.Show()
Close()
End Sub
And then in Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form1.Show()
Close()
End Sub
When I return to Form1 the OpenFileDialog behaves normally.

get file name without files extension using drag and drop vb.net

I want to drag and drop a file on a button and store the files Name without extension to a text box. Help to get out of this problem. I am getting some errors on those codes.
Private Sub Button5_DragDrop(sender As Object, e As DragEventArgs)
_Handles Button5.DragDrop
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
Dim file_name As String = Path.GetFileName(files(0))
For Each path In files
TextBox1.Text = (path)
Next
TextBox2.Text = files(0)
End Sub
Private Sub Button5_DragEnter(sender As Object, e As DragEventArgs)
_Handles Button5.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
I feel you missed setting AllowDrop feature to true
and also there is a function to get filename without extension "GetFileNameWithoutExtension"
Check the code Below
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Button5.AllowDrop = True
End Sub
Private Sub Button5_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Button5.DragDrop
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
For Each indpath In files
TextBox1.Text = Path.GetFileNameWithoutExtension(indpath) & vbNewLine & TextBox1.Text
Next
End Sub
Private Sub Button5_DragEnter(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Button5.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
End Class

I cannot find any way to convert multiple jpg or png to gif in vb.net using ffmpeg

Is there anyway i can get multiples png or jpg images to gif using ffmpeg in vb.net
I have start a new application to capture certain frames from a video but now i want to get all the frames extracted in gif image using ffmpeg.
This is my code so far:
I have in fact all ready try like this but not succeed
I have made some changes and i get the gif file but in empty state
This is my code so far
Imports System.Diagnostics
Imports System.ComponentModel
Imports System
Imports System.IO
Public Class Form1
Dim video = ""
Dim startInfo As New ProcessStartInfo("ffmpeg.exe")
Dim frame As Long 'individual frames
Dim tempdir As String = "C:\avitogifconverter\" ' images temp directory
Dim DestPath As String = "C:\avitogifconverter\"
Public Declare Auto Function FindWindowNullClassName Lib "user32.dll" Alias "FindWindow" (ByVal lpClassname As Integer, ByVal lpWindownName As String) As Integer
Dim Counter As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
My.Computer.FileSystem.CreateDirectory(tempdir)
TextBox1.Text = "exp:-->video.avi or webm or flv"
TextBox1.Clear()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim p As Process = Process.Start("cmd", "/k ffmpeg.exe -i " + TextBox1.Text + " -filter:v fps=1/15 C:\avitogifconverter\out%02d.jpg")
p.WaitForExit()
If p.HasExited Then
MsgBox("The Extraction Are Finish...")
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Label3.Text = "cmd" + "/k ffmpeg.exe -i " + TextBox1.Text + " -filter:v fps=1/15 C:\avi to gif converter\out%02d.jpg"
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If (OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK) Then
'TextBox1.Text = OpenFileDialog1.FileName
TextBox1.Text = System.IO.Path.GetFileName(OpenFileDialog1.FileName)
End If
If TextBox1.Text = Nothing Then
Return
End If
If TextBox1.Text <> Nothing Then
'My.Computer.FileSystem.CopyFile(TextBox1.Text, DestPath)
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim args As String 'declare args
args = " -framerate 1/5 -i C:\avitogifconverter\out%02d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p C:\avitogifconverter\out.gif "
Dim proc As New Process
Dim proci As New ProcessStartInfo
proci.FileName = My.Application.Info.DirectoryPath & "\ffmpeg.exe"
proci.Arguments = args
proci.WindowStyle = ProcessWindowStyle.Hidden
proci.CreateNoWindow = True
proci.UseShellExecute = False
proc.StartInfo = proci
proc.Start()
Do Until proc.HasExited = True
Me.Text = "Saving"
Loop
Me.Text = "your video done"
MsgBox("Done")
'IO.Directory.Delete(tempdir, True)
End Sub
End Class
In fact i just finish the code i finally discovery what its wrong.
This is the working code to convert mp4 to gif
So i have decided to convert first the images to mp4 and the convert the mp4 to gif
I have try to move the file to other location but wen i try to move the file to a different location its say i can not find the directory but the directory exist.
what i have miss here
this is the code
Imports System.Diagnostics
Imports System.ComponentModel
Imports System
Imports System.IO
Imports System.IO.Compression
Imports System.Windows.Forms
Imports System.Net
Public Class Form1
Dim fpsx = 10
Dim video = ""
Dim startInfo As New ProcessStartInfo("ffmpeg.exe")
Dim frame As Long 'individual frames
Dim tempdir As String = "C:\avitogifconverter\" ' images temp directory
Dim DestPath As String = "C:\avitogifconverter\"
Public Declare Auto Function FindWindowNullClassName Lib "user32.dll" Alias "FindWindow" (ByVal lpClassname As Integer, ByVal lpWindownName As String) As Integer
Dim Counter As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
My.Computer.FileSystem.CreateDirectory(tempdir)
TextBox1.Text = "exp:-->video.avi or webm or flv"
TextBox1.Clear()
TextBox2.Text = fpsx
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
fpsx = TextBox2.Text
TextBox2.Text = fpsx
Dim p As Process = Process.Start("cmd", "/k ffmpeg.exe -i " + TextBox1.Text + " -framerate 5/1 -filter:v fps=" + TextBox2.Text + " C:\avitogifconverter\out%02d.jpg")
p.WaitForExit()
If p.HasExited Then
MsgBox("The Extraction Are Finish...")
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If (OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK) Then
'TextBox1.Text = OpenFileDialog1.FileName
'TextBox1.Text = System.IO.Path.GetFileName(OpenFileDialog1.FileName)
TextBox1.Text = System.IO.Path.GetDirectoryName(OpenFileDialog1.FileName)
Dim newdialog As New OpenFileDialog()
If newdialog.ShowDialog() = DialogResult.OK Then
System.IO.File.Copy(newdialog.FileName, tempdir)
MessageBox.Show(System.IO.Path.GetDirectoryName(newdialog.FileName) & "\" & System.IO.Path.GetFileName(newdialog.FileName))
End If
End If
If TextBox1.Text = Nothing Then
Return
End If
If TextBox1.Text <> Nothing Then
'My.Computer.FileSystem.CopyFile(TextBox1.Text, DestPath)
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim args As String 'declare args
args = " -i C:\avitogifconverter\out%02d.jpg -r 10 C:\avitogifconverter\out.gif "
'args = " -i C:\avitogifconverter\out%02d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p C:\avitogifconverter\out.mp4 "
Dim proc As New Process
Dim proci As New ProcessStartInfo
proci.FileName = My.Application.Info.DirectoryPath & "\ffmpeg.exe"
proci.Arguments = args
proci.WindowStyle = ProcessWindowStyle.Hidden
proci.CreateNoWindow = True
proci.UseShellExecute = False
proc.StartInfo = proci
proc.Start()
Do Until proc.HasExited = True
Me.Text = "Saving"
Loop
Me.Text = "your video done"
MsgBox("Done")
Dim directoryName As String = "C:\avitogifconverter\"
For Each deleteFile In Directory.GetFiles(directoryName, "*.jpg", SearchOption.TopDirectoryOnly)
File.Delete(deleteFile)
Next
'IO.Directory.Delete(tempdir, True)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Form2.Show()
End Sub
End Class

How to copy a file open from open dialog to other location in vb.net

I have start a new application that converts video to image and then image to gif
every thing is ok if i put my video in side of the same folder but if i not put my video in the same folder of the project the ffmpeg its says no such file or directory. wen i click to chose my file with openfiledialog , how can i copy or move my chose video to the correct directory in this case C:\avitogifconverter\
I have try to move the file to other location but wen i try to move the file to a different location its say i can not find the directory but the directory exist. what i have miss here this is the code
This is my code
Imports System.Diagnostics
Imports System.ComponentModel
Imports System
Imports System.IO
Imports System.IO.Compression
Imports System.Windows.Forms
Imports System.Net
Public Class Form1
Dim fpsx = 10
Dim video = ""
Dim startInfo As New ProcessStartInfo("ffmpeg.exe")
Dim frame As Long 'individual frames
Dim tempdir As String = "C:\avitogifconverter\" ' images temp directory
Dim DestPath As String = "C:\avitogifconverter\"
Public Declare Auto Function FindWindowNullClassName Lib "user32.dll" Alias "FindWindow" (ByVal lpClassname As Integer, ByVal lpWindownName As String) As Integer
Dim Counter As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
My.Computer.FileSystem.CreateDirectory(tempdir)
TextBox1.Text = "exp:-->video.avi or webm or flv"
TextBox1.Clear()
TextBox2.Text = fpsx
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
fpsx = TextBox2.Text
TextBox2.Text = fpsx
Dim p As Process = Process.Start("cmd", "/k ffmpeg.exe -i " + TextBox1.Text + " -framerate 5/1 -filter:v fps=" + TextBox2.Text + " C:\avitogifconverter\out%02d.jpg")
p.WaitForExit()
If p.HasExited Then
MsgBox("The Extraction Are Finish...")
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If (OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK) Then
'TextBox1.Text = OpenFileDialog1.FileName
'TextBox1.Text = System.IO.Path.GetFileName(OpenFileDialog1.FileName)
TextBox1.Text = System.IO.Path.GetDirectoryName(OpenFileDialog1.FileName)
Dim newdialog As New OpenFileDialog()
If newdialog.ShowDialog() = DialogResult.OK Then
System.IO.File.Copy(newdialog.FileName, tempdir)
MessageBox.Show(System.IO.Path.GetDirectoryName(newdialog.FileName) & "\" & System.IO.Path.GetFileName(newdialog.FileName))
End If
End If
If TextBox1.Text = Nothing Then
Return
End If
If TextBox1.Text <> Nothing Then
'My.Computer.FileSystem.CopyFile(TextBox1.Text, DestPath)
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim args As String 'declare args
args = " -i C:\avitogifconverter\out%02d.jpg -r 10 C:\avitogifconverter\out.gif "
'args = " -i C:\avitogifconverter\out%02d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p C:\avitogifconverter\out.mp4 "
Dim proc As New Process
Dim proci As New ProcessStartInfo
proci.FileName = My.Application.Info.DirectoryPath & "\ffmpeg.exe"
proci.Arguments = args
proci.WindowStyle = ProcessWindowStyle.Hidden
proci.CreateNoWindow = True
proci.UseShellExecute = False
proc.StartInfo = proci
proc.Start()
Do Until proc.HasExited = True
Me.Text = "Saving"
Loop
Me.Text = "your video done"
MsgBox("Done")
Dim directoryName As String = "C:\avitogifconverter\"
For Each deleteFile In Directory.GetFiles(directoryName, "*.jpg", SearchOption.TopDirectoryOnly)
File.Delete(deleteFile)
Next
'IO.Directory.Delete(tempdir, True)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Form2.Show()
End Sub
End Class
I don't know why you use 2 OpenFileDialog, but anyway you don't use the System.IO.File.Copy method correctly. Both of the parameters have to be FILE PATHS. Your mistake is that you use the second parameter as DIRECTORY PATH

Using open file dialog and save file dialog with a list box in VB

I need to save things someone adds to a list and open a txt file putting it into a list box. When I open a txt file I only get one line of code and my attempts to save only produce empty txt files. Any help will be greatly appreciated. Here is my code:
Imports System.IO
Public Class Form1
Public Listed As String
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim AllText As String = "", LineOfText As String = ""
Dim StreamToDisplay As StreamReader
OpenFileDialog1.Filter = "Text files (*.txt)}|*.txt"
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Try
StreamToDisplay = My.Computer.FileSystem.OpenTextFileReader(OpenFileDialog1.FileName)
Label1.Text = OpenFileDialog1.FileName
Do Until StreamToDisplay.EndOfStream
LineOfText = StreamToDisplay.ReadLine()
'AllText = AllText & LineOfText & vbCrLf
lstBox.Items.Add(Listed)
Loop
lstBox.Items.Add(AllText).ToString()
StreamToDisplay.Close()
CloseToolStripMenuItem.Enabled = True
OpenToolStripMenuItem.Enabled = False
Catch ex As Exception
MsgBox("An error occurred." & vbCrLf & ex.Message)
End Try
End If
End Sub
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
SaveFileDialog1.Filter = "Text files (*.txt)|*.txt"
If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, lstBox.Items.ToString(), False)
End If
End Sub
Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
lstBox.Items.Clear()
Label1.Text = ""
CloseToolStripMenuItem.Enabled = False
OpenToolStripMenuItem.Enabled = True
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim Prompt As String = "Enter Items To Add Here"
Listed = InputBox(Prompt)
lstBox.Items.Add(Listed).ToString()
End Sub
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
With lstBox
.Items.Remove(.SelectedItem)
End With
End Sub
End Class
Here's a simple example that:
adds items to a ListBox
saves them to a file
loads them from a file and populates the ListBox with them
Code:
Imports System.IO
Public Class Form1
Private Sub ButtonAddItem_Click(sender As Object, e As EventArgs) Handles ButtonAddItem.Click
ListBox1.Items.Add(DateTime.Now.Ticks)
End Sub
Private Sub ButtonSave_Click(sender As Object, e As EventArgs) Handles ButtonSave.Click
If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
Using writer = New StreamWriter(SaveFileDialog1.FileName)
For Each o As Object In ListBox1.Items
writer.WriteLine(o)
Next
End Using
End If
End Sub
Private Sub ButtonLoad_Click(sender As Object, e As EventArgs) Handles ButtonLoad.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim lines = File.ReadAllLines(OpenFileDialog1.FileName)
ListBox1.Items.Clear()
ListBox1.Items.AddRange(lines)
End If
End Sub
End Class