CNAS取数仪器端升级
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

60 Zeilen
1.6KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Xml.Serialization;
  7. namespace CNAS_DBSync
  8. {
  9. public static class FileHelper
  10. {
  11. ///// <summary>
  12. ///// 获取本地XML文件值
  13. ///// </summary>
  14. ///// <param name="strPath"></param>
  15. //public void GetLocalXMLFile(string strPath)
  16. //{
  17. //}
  18. ///// <summary>
  19. ///// 保存本地XML文件值
  20. ///// </summary>
  21. ///// <param name="strPath"></param>
  22. //public void SaveLocalXMLFile(string strPath)
  23. //{
  24. //}
  25. /// <summary>
  26. /// 获取当前dll所在目录
  27. /// </summary>
  28. /// <returns></returns>
  29. public static string getBasePath()
  30. {
  31. //获取当前DLL 所在路径
  32. string dllpath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
  33. if (dllpath != null && dllpath.Length > 0) dllpath = dllpath.Substring(8) + @"\";
  34. FileInfo tmpDllInfo = new FileInfo(dllpath);
  35. dllpath = tmpDllInfo.DirectoryName;
  36. dllpath = dllpath.Replace(tmpDllInfo.Directory.Name, "");
  37. return dllpath;
  38. }
  39. public static List<T> XmlToList<T>(string xml, string rootName) where T : class
  40. {
  41. XmlSerializer serializer = new XmlSerializer(typeof(List<T>), new XmlRootAttribute(rootName));
  42. using (StringReader sr = new StringReader(xml))
  43. {
  44. List<T> list = serializer.Deserialize(sr) as List<T>;
  45. return list;
  46. }
  47. }
  48. }
  49. }