编写ascii代码文件并检查它的方式 [英] the way to write ascii code file and Check it

查看:102
本文介绍了编写ascii代码文件并检查它的方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须写一个ASCII并有一个schemah,每行应该是128个字符,我接受了一个字符串和一个字符串,并附加了它,以便每个字段都接收到他的位置,测试正好是128个字符,但是在edit.com中不是正确的地方,我问如何使文件的ascii代码?有没有一种方法可以将每个字符串写到某个位置? 我不能上载不是英语的schamah,而且我不会说英语,并且为自己的错误感到抱歉.

I have to write an ASCII and have the schemah, each row should be 128 characters, I took string and string and attached so that each field received his position, the test was exactly 128 characters, but in edit.com it's not the right place, I asked how to make the file ascii code? And is there a way to write each string a certain position? I can not upload the schamah is not in English, also, it i do not speak English and sorry for the mistakes.

预先感谢

推荐答案

您很可能不使用ASCII编码来编写文件-尝试以下操作:

You most likely don't write your file with ASCII encoding - try this:

string myRow =string.Join("", Enumerable.Repeat("A", 128));
string[] rows = new string[] { myRow, myRow };
File.WriteAllLines(@"test.txt", rows, Encoding.ASCII);

这将生成一个文本文件,其中的每一行均以ASCII编码(每个字符一个字节),并且行由\r\n字符分隔.该示例生成的文件大小为260个字节,每行128个字节,再加上两个字符的2倍用于行分隔.

This produces a text file where each line is encoded in ASCII (one byte per character) and rows are separated by \r\n characters. The sample produces a file with a size of 260 bytes, 128 bytes for each row plus 2x the two characters for line seperation.

这篇关于编写ascii代码文件并检查它的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆