|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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
- {
- ///// <summary>
- ///// 获取本地XML文件值
- ///// </summary>
- ///// <param name="strPath"></param>
- //public void GetLocalXMLFile(string strPath)
- //{
-
- //}
-
-
- ///// <summary>
- ///// 保存本地XML文件值
- ///// </summary>
- ///// <param name="strPath"></param>
- //public void SaveLocalXMLFile(string strPath)
- //{
-
- //}
-
-
- /// <summary>
- /// 获取当前dll所在目录
- /// </summary>
- /// <returns></returns>
- 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<T> XmlToList<T>(string xml, string rootName) where T : class
- {
- XmlSerializer serializer = new XmlSerializer(typeof(List<T>), new XmlRootAttribute(rootName));
- using (StringReader sr = new StringReader(xml))
- {
- List<T> list = serializer.Deserialize(sr) as List<T>;
- return list;
- }
- }
- }
- }
|