本文介绍了不同的文件大小C ++到C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我刚刚被要求将一些旧的遗留C ++代码移植到C#,程序非常简单 - 它从文本文件中解析一些数据并将其写入另一个。一切正常但是 - 作为我测试的一部分,每当我做这样的事情时,我都会使用devenv.exe中的文件比较功能(以为它曾经被称为windiff)



Hi All, I've just been asked to port some old legacy C++ code to C#, the program is pretty simple - it parses some data from a text file and writes it out to another. All works ok BUT - as part of my testing whenever I do stuff like this I use the file compare function in devenv.exe ( think it used to be called windiff )

devenv /diff file1 file2 



一切都很好,但是 - 如果我逐字节比较它会失败,因为文件大小不同(C#one大128个字节)

任何想法的人?它不是一个节目限制器我只是好奇。



我尝试过:



在这里搜索和发布!


and all is good, BUT - If I do a byte by byte comparison it fails as the files are different sizes ( the C# one is 128 bytes larger)
Any ideas guys ? it's not a show stopper I'm just curious.

What I have tried:

Googling and posting on here !

推荐答案

Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode;
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);


这篇关于不同的文件大小C ++到C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 11:55