Пример #1
0
 /// <summary>
 /// 序列化xml文件。将新建内容加入xml
 /// </summary>
 /// <param name="hsdh">新建内容</param>
 public void Add(HelpSyncDirectoryHistory hsdh)
 {
     XmlSerializer writer = new XmlSerializer(typeof(HelpSDHxml));
     var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "//pair.xml";
     FileStream file;
     file = System.IO.File.OpenWrite(path);
     this.HelpSyncDirectoryHistories.Add(hsdh);
     writer.Serialize(file, this);
     file.Close();
 }
Пример #2
0
        /// <summary>
        /// xml文件初始化
        /// </summary>
        /// <returns></returns>
        private HelpSDHxml Init()
        {
            XmlSerializer writer =
                new XmlSerializer(typeof(HelpSDHxml));

            var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "//pair.xml";
            FileStream file;
            file = System.IO.File.OpenWrite(path);
            HelpSyncDirectoryHistory hsdh = new HelpSyncDirectoryHistory()
            {
                Id = 0,
                PairName = "Index",
                LeftDirectoryName = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                RightDirectoryName = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                LR =
                    AppDomain.CurrentDomain.SetupInformation.ApplicationBase + " < Sync > " +
                    AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                SyncType = "Sync",
                SyncTypeId = 0
            };
            HelpSDHxml tmp = new HelpSDHxml();
            tmp.HelpSyncDirectoryHistories.Add(hsdh);
            writer.Serialize(file, tmp);
            file.Close();
            return tmp;
        }