使用c#将文件内容作为字符串获取 [英] get file content as string using c#

查看:73
本文介绍了使用c#将文件内容作为字符串获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi


我正在从文件夹中读取Xml文件如何使用c#将所有xml内容作为字符串获取,



i已谷歌搜索,但我只阅读文件的名称。

hi
I am reading a Xml file from folder how can get all xml content as string using c#,

i have googled but i got only to read the names of the file.

推荐答案

string content = File.ReadAllText(@"path-to-file.xml");



应该这样做。



-KR


This should do.

-KR


this并不是你所要求的全部,但这是一个开始 https:// msdn .microsoft.com / zh-cn / library / s2tte0y1(v = vs.110).aspx [ ^ ]



从那里你可以做一个字符串。加入以实现结果
this isnt quite 'all' you asked for but it's a start https://msdn.microsoft.com/en-us/library/s2tte0y1(v=vs.110).aspx[^]

from there you could do a String.Join to achieve the result


这篇关于使用c#将文件内容作为字符串获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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