顺序文件处理 [英] Sequential File Handling

查看:68
本文介绍了顺序文件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用打印"函数编写纯文本顺序文件.理想地,打印"打印.功能应附加一个"New Line"(换行)字符(回车[ASCII = 13]和换行符[ASCII = 10]的组合)在打印"

后指定的文本末尾,例如:打印#1 ,"Hello"应该用"New Line"(新行)打印Hello末尾的字符.

在某些计算机上,未附加此换行符.仅换行"被附加但未附加回车"

这反过来给读取代码带来了问题:Line Input#1,StrLine

我尝试使用FileSystem读取文件目的.由于它仅取决于换行",因此效果很好.而不是在新行"上

请让我知道为什么打印"字样会变大.功能无法添加新行"在某些情况下,请在末尾输入字符.

在任何情况下,我都无法复制此错误.我在具有不同Service Pack的不同Windows版本上进行了尝试.

I am using "Print" function to write a plain text sequential file. Ideally "Print" function should append a "New Line" character (combination of Carriage Return [ASCII=13] & Line Feed [ASCII=10]) at the end of the text specified after "Print"

eg: Print #1, "Hello" should print Hello with a "New Line" character at the end.

On some machines this new line character is not appended. Only "Line Feed" gets appended but not the "Carriage Return"

This in turn creates a problem for reading code: Line Input #1, StrLine

I have tried reading the file using FileSystem Object. This works fine as it depends only on the "Line Feed" and not on "New Line" character.

Please let me know why the "Print" function is unable to append a "New Line" character at the end in some cases.

I am not able to replicate this error in any of the circumstances. I tried on different Windows versions with different Service Packs.

推荐答案

尝试使用流读取器和流写入器代替旧打印"功能.
(我不确定该Print是否仍在Framework 4.0中,但是print是在MSDN上搜索的一个好词).



http://msdn.microsoft.com/en-us/library/system.io. streamwriter.aspx
Try to use the streamreader and the streamwriter instead of the Old Print function.
(I'm not sure if the Print is even still in Framework 4.0, but print is a hart word to search for on MSDN).



http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx


这篇关于顺序文件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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