您的位置:首页 > 其它

根据文件路径 读取xml文件文本

2012-06-26 16:58 162 查看
/// <summary>
/// 根据文件路径 读取xml文本
/// </summary>
/// <param name="xmlFilePath"></param>
/// <returns></returns>
public string ReadTXTByFileName(string FilePath)
{
string strMsg = string.Empty;
try
{
XmlDocument doc = new XmlDocument();
doc.Load(System.Web.HttpContext.Current.Server.MapPath(FilePath));
strMsg = doc.InnerXml;

//读取文本内容(txt内容)
//FileInfo fi = new FileInfo(System.Web.HttpContext.Current.Server.MapPath(FilePath));
//StreamReader sr = fi.OpenText();
//strMsg = sr.ReadToEnd();
//sr.Close();
}
catch (Exception ex)
{
strMsg = "Error";
}
return strMsg;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: