Hi! I'm new to the
VB.NET programming, well programming in general actually. I hope I am posting this in the right section.
I'm writing an application that pops up an OpenFile dialog, then writes the path of the selected file in a .txt file, so that an outside application can read it.
Here is the code that is supposed to do that:
Private Sub btnIzberi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIzberi.Click
Dim strFileName As String
With OpenFileDialog1
.Filter = "Text files (*.txt)|*.txt"
.FilterIndex = 1
.InitialDirectory = "C:\"
.Title = "Choose a text file"
End With
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
strFileName = OpenFileDialog1.FileName
Dim pisalnik As New StreamWriter(MyFile)
pisalnik.WriteLine(strFileName)
pisalnik.Close()
Else
Exit Sub
End If
txtAnalizaCrkInParov.Text = "You selected the file: " & strFileName
End Sub
There is also a button that launches the external application that is supposed to read the file.
My problem is that the application CANNOT read the file I created (MyFile), therefore can't do it's job right.
Why won't StreamWriter let go of the file, so that an external application can use it? My best guess is that it has something to do with the OpenFileDialog, but I have no idea what, or how to fix it.
Please help me, I'm dying over here! :\
Greetz, cheh
Slovenian Hardstyle Community