Hello, does anybody out there know how to change a single word in a text document. Right now I'm using VB.net to read a word in a text document (it's the only word in there), I would like to be able to change that word using visual basic. Any help will be greatly appreciated.
Changing a word in a .txt document with VB.net
Collapse
X
-
Tags: None
-
Originally posted by spazzo6281Hello, does anybody out there know how to change a single word in a text document. Right now I'm using VB.net to read a word in a text document (it's the only word in there), I would like to be able to change that word using visual basic. Any help will be greatly appreciated.
Hi
Please submit what you have written so far
regards -
Originally posted by TenneysonHi
Please submit what you have written so far
regardsCode:My.Computer.FileSystem.ReadAllText(file path)
Comment
-
I wud:...
1. Read the whole file
2. process it in vb
3. truncate the file
4. write the new data back to the fileComment
-
-
Thanks for you help but for some reason I just can't figure it out. This is the code i have so far:
Code:my.computer.filesystem.readalltext("I:\msctc moorhead archive\word.txt")
How would I go about changing that word using textboxes in VB.net.Comment
-
I have gotten the code figured out. This is what it wound up being:
Code:Dim text1 As String = txtOldP.Text Dim text2 As String = txtNewP1.Text Dim pword As String = My.Computer.FileSystem.ReadAllText("I:\MSCTC Moorhead Archive\word.txt", System.Text.ASCIIEncoding.ASCII) My.Computer.FileSystem.WriteAllText("I:\MSCTC Moorhead Archive\word.txt", pword.Replace(txtOldP.Text, txtNewP1.Text), False)
Comment
Comment