/// <summary>
 /// 保存配置文件
 /// </summary>
 public static bool SaveConfigData()
 {
     if (ConfigDataService.ConfigData != null)
     {
         //string path = System.Environment.CurrentDirectory + @"\config.json";
         StringConvert.FileWrite(FilePath, StringConvert.ListToJson(ConfigDataService.ConfigData));
         return(true);
     }
     return(false);
 }
Exemple #2
0
        /// <summary>
        /// 将文件保存成data.js文件
        /// </summary>
        /// <param name="localBookmarks">本地书签文件数据</param>
        public static void SaveDataJs(List <MyBookmarks> localBookmarks)
        {
            string dataPath   = System.Environment.CurrentDirectory + @"\data.json";
            string datajsPath = System.Environment.CurrentDirectory + @"\data.js";

            if (BookmarksData.SaveMyBookmarksToJsonFile(localBookmarks, dataPath))
            {
                string cont = "var InfoData =" + StringConvert.FileRead(dataPath);
                StringConvert.FileWrite(datajsPath, cont);
            }
        }
Exemple #3
0
        /// <summary>
        /// 保存成json文件
        /// </summary>
        /// <param name="myBookmarkses"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool SaveMyBookmarksToJsonFile(List <MyBookmarks> myBookmarkses, string filePath)
        {
            BookmarksType bookmarksType = new BookmarksType();

            bookmarksType.Info = myBookmarkses;
            List <string> types = new List <string>();

            foreach (var item in myBookmarkses.GroupBy(a => a.Type).ToList())
            {
                types.Add(item.Key);
            }
            bookmarksType.Type = types;
            return(StringConvert.FileWrite(filePath, StringConvert.ListToJson(bookmarksType)));
        }