I am trying to read a text file placed on the desktop using the following piece of code. Unfortunately, the text which is read is gibberish. Can someone please help me out how to read text files correctly.
And how to work the the content of the text file, like finding strings?
myFile = aqFile["OpenTextFile"](sPath, aqFile.faRead,aqFile.ctUnicode);
var sFile = myFile["ReadAll"]();
Output: See attached picture
Just to double-check: are you sure that the file is really in Unicode format, but not in, say, UTF-8 one?
Yes I changed the Unicode format.
Now that has been resolved, how to access the content of this file and search for a word within this file?
The content of the file is in the sFile variable.
You may use methods provided by the aqString object (see help for details) or use regular expressions or any other means that works best for the given file content.
Open file in Notepad and save in unicode or whatever format you are using in TextCoding Type
2. for searching in particular line use
var myFile = aqFile.OpenTextFile(sPath, aqFile.faRead, aqFile.ctUnicode);
s = myFile.ReadLine();
aqString.Find(InputString, SubString, StartPosition, CaseSensitive)
Thanks for your help, guys!
@komalak11, did these suggestions help you resolve the question? Please mark the best answer as a solution.