I think I found the problem
I think should be using
byte[] readText = File.ReadAllBytes(AuthFile.FullPath);
( now if I can get past the "not access" error)
Tim
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have an encrypted file that contains the following chars.
áÒá,èÜÒè
what I see when debugging is Black diamonds containing "?".
I think my open/read file is using the wrong file data type. (unicode, ascii, etc..)
and not correctly reading the data, thus preventing my decryption code from working.
using (var stream = await AuthFile.OpenReadAsync())
{
using (var reader = new StreamReader(stream))
{
while ((line = reader.ReadLine()) != null)
{ ...
if this helps,
the file is created by a VBScript using the following code line.
Set objFileToWrite = CreateObject("Scripting.FileSystemObject").OpenTextFile("c:\vbscripts\pid.txt",2,true)
TIA
Tim
I think I found the problem
I think should be using
byte[] readText = File.ReadAllBytes(AuthFile.FullPath);
( now if I can get past the "not access" error)
Tim
Hi @tim , Welcome to Microsoft Q&A,
By default, StreamReader
uses UTF-8 encoding, but it seems that your file might have been created with a different encoding (such as ANSI or a different character set). To resolve this, you should explicitly specify the encoding when reading the file.
You can modify your StreamReader
to use a specific encoding, such as Encoding.Default
(which uses the system's default encoding, often ANSI) or another suitable encoding like Encoding.GetEncoding("ISO-8859-1")
if needed.
When you use byte[] readText = File.ReadAllBytes(AuthFile.FullPath); to read a file, File.ReadAllBytes will directly read the byte data of the file without relying on the encoding.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.