frank-in-bahia
Member
- Joined
- Oct 6, 2013
- Messages
- 7
- Programming Experience
- Beginner
I'm not sure if my title correctly defines the problem, but here it is. As per the code below, I'm using Streamwriter to write a new file which the user has created. It works perfectly. But when I go to open the new file itself, I find that although it has the .txt extension, Windows doesn't recognize it as a text file and the "open with what" dialog pops up. (When I select Notepad, it opens normally.) In Properties for the file, it simply says "Type of File: File".
What am I missing?
(I'm using Visual Studio Express 2012 and Windows 8.)
Many thanks!
What am I missing?
(I'm using Visual Studio Express 2012 and Windows 8.)
Many thanks!
VB.NET:
Private Sub btnSaveFile_Click(sender As Object, e As EventArgs) Handles btnSaveFile.Click
' (this section lets the user name a new .txt. file and its path, which appears in a "txtDestination" textbox)
SaveFileDialog1.Title = "Specify Destination Filename"
SaveFileDialog1.Filter = "Text Files (*. txt) |*. txt"
SaveFileDialog1.FilterIndex = 1
SaveFileDialog1.OverwritePrompt = True
If SaveFileDialog1.ShowDialog() <>
Windows.Forms.DialogResult.Cancel Then
txtDestination.Text = SaveFileDialog1.FileName
End If
' (this section creates the new .txt file and fills it with 2 test lines)
Dim fileNameandPath As String
fileNameandPath = txtDestination.Text
Dim objFile As New System.IO.StreamWriter(fileNameandPath)
objFile.Write("test 1" & vbCrLf)
objFile.Write("test 2")
objFile.Close()
End Sub