Click here to Skip to main content
15,903,201 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to modify a notepad; and that is not a big deal.
When i save the data automatically an extra space over there.
Textbox data is very case sensitive; actually it saves server name so an extra space will hamper in the connection.

Any suggetion...
Thanks in advance
Posted
Comments
sahabiswarup 16-Nov-11 23:18pm    
here is my code snippet:
Private Sub ButtonHover1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonHover1.Click
Dim lineToWrite As String = txtserver.Text
Dim destinationFile As String = (Application.StartupPath & "\ServerName.txt")
If lineToWrite = "" Then
MessageBox.Show("Server name cannot be blank")
Else
Dim lines As String() = File.ReadAllLines(destinationFile)
Using writer As New StreamWriter(destinationFile)
writer.WriteLine(lineToWrite)
txtserver.Text = ""
MessageBox.Show("Server name updated")
End Using
End If
End Sub
wizardzz 17-Nov-11 0:23am    
you should edit your original post and include this code there, instead of as a comment.

1 solution

Now you are doing is writing line by line.
Which will generate a new line after writing each line by default. So the better idea is to us writer.write("your text") instead of writer.writeline("your text").
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900