Пример #1
0
 //============================================================
 // <T>获得指定文件名称的路径。</T>
 //
 // @param fileName 文件名称
 // @return 路径
 //============================================================
 public static string Location(string fileName)
 {
     if ((null != fileName) && !fileName.Contains(RFile.DRIVER_SPLITER))
     {
         return(RFile.MakeFileName(Location(), fileName));
     }
     return(fileName);
 }
Пример #2
0
        protected void LoadConfig(string name)
        {
            Assembly  assembly = Assembly.GetEntryAssembly();
            FFileInfo info     = new FFileInfo(assembly.Location);

            _path = info.DirectoryName;
            // Make file name
            string file = null;

            if (name != null && name.IndexOf(':') != -1)
            {
                file = name;
            }
            else
            {
                AssemblyName aname = assembly.GetName();
                if (name == null)
                {
                    file = RFile.MakeFileName(_path, aname.Name);
                }
                else
                {
                    file = RFile.MakeFileName(_path, name);
                }
                if (!file.EndsWith(TYPE_XML))
                {
                    file += TYPE_XML;
                }
            }
            // Load config
            FXmlDocument xdoc = new FXmlDocument();

            //xdoc.Formater.Formater = this;
            _exists = File.Exists(file);
            if (_exists)
            {
                _exists = true;
                xdoc.LoadFile(file);
            }
            // Set config
            _config = xdoc.Root;
            BuildConfigMap(_config);
        }
Пример #3
0
        //============================================================
        // <T>从文件中加载所有信息。</T>
        //============================================================
        public void RestoreFiles()
        {
            // 保存属性
            string    configName = RFile.MakeFileName(_storagePath, "applications.ser");
            FByteFile file       = new FByteFile(configName);
            // 写入个数
            int count = file.ReadInt32();

            // 保存所有程序信息
            for (int n = 0; n < count; n++)
            {
                FApplicationInfo info = new FApplicationInfo();
                info.Name = file.ReadString();
                // 保存程序信息
                string fileName = RFile.MakeFileName(_storagePath, info.Name + ".ser");
                info.LoadFile(fileName);
                _infos.Push(info);
                _activeInfo = info;
            }
        }
Пример #4
0
        //============================================================
        // <T>存储所有信息到文件中。</T>
        //============================================================
        public void StoreFiles()
        {
            // 保存属性
            FByteFile file = new FByteFile();
            // 写入个数
            int count = _infos.Count;

            file.WriteInt32(count);
            // 保存所有程序信息
            for (int n = 0; n < count; n++)
            {
                FApplicationInfo info = _infos.Get(n);
                file.WriteString(info.Name);
                // 保存程序信息
                string fileName = RFile.MakeFileName(_storagePath, info.Name + ".ser");
                info.SaveFile(fileName);
            }
            // 保存文件
            string configName = RFile.MakeFileName(_storagePath, "applications.ser");

            file.SaveFile(configName);
        }