为什么我的保存文件全部都放在一行上? [英] Why is my save file all on one line?

查看:90
本文介绍了为什么我的保存文件全部都放在一行上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

Caffine供电的项目现在即将结束,所以我正在检查一些东西
并查看了一个保存文件,发现所有数据都在一行上,几乎就像它没有正确分割输入一样,该单元如何在一行上全部返回了数据,
尽管输入了\ n,但是,如果我使用消息框显示字符串,则希望将其写入文件"Unit_Reply_Modded",所有数据均显示正确的间距,因此我用

Hi All,

The caffine powered project is now nearing sign off so I was checking some thing
and looked in a save file and found the data all on one line, almost like it is not splitting the input correctly how ever the unit returns the data all on one line,
despite having \n put in however if I use a message box to display the string I wish to write to the file " Unit_Reply_Modded " all the data appear correctly spaced so I write it with

sw.WriteLine(Unit_Reply_Modded);


全部显示在一行上.我已经在XP上进行了测试,唯一改变的地方是我现在正在使用Win7(XP机器死了),因为数据在文本框中的格式正确,所以我在考虑是否将字符串读入foreach循环并写入\ r \ n.请对此发表意见(我的午餐时间又来了!)

Glenn


It all appears on the one line. I have been testing this on XP the only thing that has changed is I am now using Win7 (the XP machine died), as the data is correctly formatted in the text box I am thinking if I read the string into a foreach loop and write it out with a \r\n. opions on this please (there goes my lunch hour again!)

Glenn

推荐答案

大家好,

这是我远离办公桌的解决方案(优先考虑"MORE"的其他事项),看来我将要在家中安装安装程序!
这是解决问题的方法,当我键入问题时,我确实想到了这个问题
Hi All,

Heres the solution I was away from my desk (something else "MORE" important took priority) Looks I am going to be building installers at home!!
Heres What solved the problem I did think of this as I was typing the question
foreach (string subString in Unit_Reply_Modded.Split('\n'))
{
    //MessageBox.Show(subString);
    sw.WriteLine(subString);
}


我这样做的次数比我想承认的要多.
格伦(Glenn)


I do that more often than I would like to admit.
Glenn


,如果您正在写入新文件或重写现有文件
使用
if your are writing to a new file or owerwriting to existing file
use
sw.Write(Unit_Reply_Modded);



代替


insteed of

sw.WriteLine(Unit_Reply_Modded);


这对您有帮助
或在读取时使用split


this will help you
or at the time of reading to each line with split

yourTextControl.Text.Split(new char[] { '\r' });


这篇关于为什么我的保存文件全部都放在一行上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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