如何使用streamwriter. [英] How to use streamwriter.

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

问题描述

HI 我正在使用Streamwriter,但我不知道如何使用它.我把所有数据都放在字符串上,并将其拆分为数组,并在数组的特定位置添加一些文本,我想把所做的任何更改添加到桌面上,并做一些修改,但是我做不到,你能帮我吗.

问候

Cute Jyoti

HI I am using streamwriter, but i dont know how to use it. i take all the data in on string and split it in array and adding some text at perticular location in array and i want write that file on desktop with changes addition whatever it done but i ma not able to do it can u help me..

Regards

Cute Jyoti

推荐答案

尝试一下.
Try this.
StreamWriter writer = new StreamWriter("[DirectoryPath]\test.txt", true);
writer.Write(yourstring);
writer.Close();


检查下面的链接以获取更多详细信息.

http://www.java2s.com/Code/CSharp/File-Stream/UsingStreamWriter3.htm [ ^ ]


Check the below link for more details.

http://www.java2s.com/Code/CSharp/File-Stream/UsingStreamWriter3.htm[^]


可能会帮助您,

Might help you,

static void Main(string[] args)
{

    string myString = "Hello World ! I am a string";
    string[] splitedString = myString.Split(new char[] { ' ' }).Select(item => (item == "!") ? "." : item).ToArray();
    string processedResult=default(string);
    Array.ForEach(splitedString, item =>
    {
        processedResult = string.Concat(processedResult, item);
    });

    using (StreamWriter sw = new StreamWriter(@"c:\temp\MyFile"))
    {
        sw.WriteLine(processedResult);
    }
}



:)



:)


这篇关于如何使用streamwriter.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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