Exemple #1
0
        public LoadResult Load(string filename, bool autoBackup = false)
        {
            LoadResult result = LoadResult.Success;

            _fileInfo = new FileInfo(filename);
            _entries  = null;

            if (_fileInfo.Exists)
            {
                _kbd = new KBD(File.OpenRead(_fileInfo.FullName));

                string backupFilePath = _fileInfo.FullName + ".bak";
                if (File.Exists(backupFilePath))
                {
                    _kbdBackup = new KBD(File.OpenRead(backupFilePath));
                }
                else if (autoBackup || MessageBox.Show("Would you like to create a backup of " + _fileInfo.Name + "?\r\nA backup allows the Original text box to display the source text before edits were made.", "Create Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    File.Copy(_fileInfo.FullName, backupFilePath);
                    _kbdBackup = new KBD(File.OpenRead(backupFilePath));
                }
                else
                {
                    _kbdBackup = null;
                }
            }
            else
            {
                result = LoadResult.FileNotFound;
            }

            return(result);
        }
Exemple #2
0
        public bool Identify(string filename)
        {
            using (var br = new BinaryReaderX(File.OpenRead(filename)))
            {
                try
                {
                    var obj = new KBD(br.BaseStream);
                }
                catch
                {
                    return(false);
                }

                return(true);
            }
        }