Common/XmlHelper.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Xml;
using System.Data;
using System.IO;

namespace MyShop.Common
{
    public static class XmlHelper
    {
        public static DataSet GetDataSet(string xmlFilePath)
        {

            DataSet dataset = new DataSet();

            if (File.Exists(xmlFilePath))
            {
                dataset.ReadXml(xmlFilePath);
            }

            return dataset;
        }

        public static bool WriteTableToXml(DataTable dt, string xmlFilePath)
        {
            try
            {
                dt.WriteXml(xmlFilePath);
                return true;
            }
            catch
            {
                return false;
            }
        }


        public static bool WriteDataSetToXml(DataSet ds, string xmlFilePath)
        {
            try
            {
                ds.WriteXml(xmlFilePath);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool DeleteTableRows(DataTable dt, int index, string xmlFilePath)
        {
            dt.Rows[index].Delete();
            return WriteTableToXml(dt, xmlFilePath);
        }

        public static bool DeleteTableRowsInDataSet(DataSet ds, int tableIndex, int rowIndex, string xmlFilePath)
        {
            ds.Tables[tableIndex].Rows[rowIndex].Delete();
            return WriteDataSetToXml(ds, xmlFilePath);
        }
后面还有 5 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。