I'm trying to store text I read from a file to a string variable:
using HtmlAgilityPack;
// .
// .
// some other code
// .
// .
// The following line's output is as expected. The contents of the file is printed to the console.
Console.Write( File.ReadAllText( parentFolder + @"\" + file ) );
// (storing the text in a variable)
node.InnerHtml = File.ReadAllText( parentFolder + @"\" + file );
// The output of the following line is different. The spaces and new lines become ="" (equal symbol + 2 sets of quotation marks + a space)
Console.Write( node.InnerHtml );
// example output of Console.Write( File.ReadAllText( parentFolder + @"\" + file ) );
// 'use strict';
//
// module.exports = somevariable;
// example output of Console.Write( node.InnerHtml );
// 'use="" strict';="" module.exports="somevariable;
What could be causing this? And how can it be fixed?
`. My guess is that HmtlAgilityPack is removing whitespace because it's meaningless in HTML. – ProgrammingLlama Sep 08 '21 at 05:47