using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace CNAS_DBSync
{
public static class FileHelper
{
/////
///// 获取本地XML文件值
/////
/////
//public void GetLocalXMLFile(string strPath)
//{
//}
/////
///// 保存本地XML文件值
/////
/////
//public void SaveLocalXMLFile(string strPath)
//{
//}
///
/// 获取当前dll所在目录
///
///
public static string getBasePath()
{
//获取当前DLL 所在路径
string dllpath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
if (dllpath != null && dllpath.Length > 0) dllpath = dllpath.Substring(8) + @"\";
FileInfo tmpDllInfo = new FileInfo(dllpath);
dllpath = tmpDllInfo.DirectoryName;
dllpath = dllpath.Replace(tmpDllInfo.Directory.Name, "");
return dllpath;
}
public static List XmlToList(string xml, string rootName) where T : class
{
XmlSerializer serializer = new XmlSerializer(typeof(List), new XmlRootAttribute(rootName));
using (StringReader sr = new StringReader(xml))
{
List list = serializer.Deserialize(sr) as List;
return list;
}
}
}
}