-1

I want replace 1 word in text file (file format is not .txt) file Unicode is (UTF16) few text example:

I D = " f f 0 3 4 a 9 2 - d d 9 f - 4 3 7 4 - a 8 a d - f 5 5 4 0 0 2 a 4 1 9 b " I S S U E _ D A T E = " 2 0 1 7 - 0 2 - 1 6 T 1 7 : 2 9 : 1 8 . 9 7 0 2 2 9 4 Z " S E Q U E N C E = " 0 " M A N A G I N G _ A P P L I C A T I O N _ T O K E N = " " > < L I C E N S E P U B L I C _ I D = " 3 A A - U J F - 8 K P " U S E R N A M E = " N d a G 6 Z T w u v I X Z B i t h 8 g o d d Q x E r x 0 + O g M c t 0 2 3 f X K O E w = " P A S S W O R D = " F 9 b n 6 b v w l f I 5 Z A 2 t h M h 9 d d s x Q L w = " T Y P E = " T R I A L " F L A G S = " 4 " D I S P L A Y _ N A M E =

I want change T R I A L to other word

Ňɏssa Pøngjǣrdenlarp
  • 38,411
  • 12
  • 59
  • 178
reza
  • 1

1 Answers1

0

It's not too hard to modify your text file. Use the IO class to assign it to a text file, then use String.Replace(oldValue As String, newValue As String) to change your string. Then use IO again to save the string to the file. This should work so long as your file isn't open and being used in another program - regardless of file extensions.

An example, to help you, could be something such as this:

Dim myFileContents as String = IO.File.ReadAllText("Path\To\My\File\File.extension")
myFileContents = myFileContents.Replace("T R I A L", "Some other word")
IO.File.WriteAllText("Path\To\My\File\File.extension", myFileContents)

Modify the contents to suit your situation - however, this is only a basic implementation. Additionally, it is important to note that String.Replace() will change all occurrences of your word to the new word.

Ally
  • 467
  • 5
  • 24
  • Me thinks his issue is more to do with the file encoding. Either he doesn't know how to read and write the correct format, or the text file has no header to identify it as Unicode and he needs to force it. I can't tell which from the question though. – Trevor_G Feb 18 '17 at 15:25
  • with this code remove all space and changed UTF to UTF8 - not change T R I A l – reza Feb 21 '17 at 12:50