Im trying to load a text file from a specific location. What I need to do is find a way to allow my code to open a textfile from specific folder, basically what im trying to do it make it open to the desktop then assignment1 folder and thats it( the files in there) the only problem is, im going to have to zip the file (with the textbox in it) and the other person is going to have to reopen it. What I want tot do is open right to the textbox and no where else, this is my code
Private Sub btnload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnload.Click ListBox1.Items.Clear() Dim ofd As New OpenFileDialog ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments ' where it opens up ofd.Filter = "Text files (*.txt)|*.txt" Dim result As DialogResult = ofd.ShowDialog Dim fileContent As String = Nothing Dim fileLines() As String If result = Windows.Forms.DialogResult.OK AndAlso ofd.FileName <> String.Empty Then Using sr As New System.IO.StreamReader(ofd.FileName) fileContent = sr.ReadToEnd sr.Close() End Using End If fileLines = fileContent.Split(Convert.ToChar(vbLf)) For index As Integer = 0 To fileLines.GetUpperBound(0) ListBox1.Items.Add(fileLines(index)) Next End Sub
But when I zip the file and send it, he could unzip the file to a different location then the desktop, is there a way to allow the load button to open specifically to the textbox when its zipped or do I have to tell him where the text file is?