Two identical files have different file size based on the way it is written from C# Two identical files have different file size based on the way it is written from C# json json

Two identical files have different file size based on the way it is written from C#


Even though the content of both the files are same, they have different file size.

If they have a different size, then they definitely have different contents. A file is (pretty much) just a sequence of bytes - and if two sequences have different lengths, they're different sequences.

In this case, the two files both represent the same text, but using different encodings - file2 will use UTF-8, and file1 will use UTF-16.

To think of it a different way: if you saved the same picture to two files, one as JPEG and one as PNG, would you expect the files to be the same size?