Exemple #1
0
        public bool MakeBook(string FilePath, string author, string displayName, string tooltip)
        {
            //Copy书本,其实检查应该在获取FilePath时就做好的。
            if (!File.Exists(FilePath))
            {
                System.Windows.MessageBox.Show("未找到文件!" + FilePath, "错误", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return(false);
            }
            var mapName = FilePath.Split('\\').Last();

            //是否覆盖呢?
            File.Copy(FilePath, Properties.Settings.Default.真目录 + '\\' + mapName);
            var path = Properties.Settings.Default.真目录 + '\\' + mapName + ".txt.ini";

            File.Create(path);
            //写入
            if (OperateIniFile.write("Info", "Name", mapName, path) &&
                OperateIniFile.write("Info", "Author", author, path) &&
                OperateIniFile.write("Info", "DisplayName", displayName, path) &&
                OperateIniFile.write("Info", "Tooltip", tooltip, path))
            {
                return(true);
            }
            System.Windows.MessageBox.Show("写入错误!"); //不够全
            return(false);
        }
Exemple #2
0
        public BookManager()
        {
            /*开始索引*/
            string e = "error";

            links = new Dictionary <string, Book>();
            DirectoryInfo folder = new DirectoryInfo(Properties.Settings.Default.真目录);

            foreach (var item in folder.GetFiles("*.txt.ini"))
            {
                string path        = Properties.Settings.Default.真目录 + '\\' + item;
                string mapName     = OperateIniFile.read("Info", "Name", e, path);
                string auther      = OperateIniFile.read("Info", "Author", e, path);
                string displayName = OperateIniFile.read("Info", "DisplayName", e, path);
                string tooltip     = OperateIniFile.read("Info", "Tooltip", e, path);
                links.Add(mapName, new Book(mapName, auther, displayName, tooltip));
            }
        }