Exemplo n.º 1
0
        public EPFArchiveEntry ReplaceEntry(string entryName, string filePath)
        {
            if (_mode == EPFArchiveMode.Read)
            {
                throw new InvalidOperationException("Unable to replace any entry in read-only mode");
            }

            var oldEntry = FindEntry(entryName);

            if (oldEntry == null)
            {
                throw new ArgumentException($"Entry {entryName} doesn't exists.");
            }

            oldEntry.Dispose();

            var entryIndex = _entries.IndexOf(oldEntry);

            var newEntry = new EPFArchiveEntryForCreate(this, entryName, filePath);

            _entries[entryIndex]            = newEntry;
            _entryDictionary[newEntry.Name] = newEntry;

            ModifiedEntriesNo++;

            RaiseEntryChanged(newEntry, EntryChangedEventType.Replaced);
            return(newEntry);
        }
Exemplo n.º 2
0
        public EPFArchiveEntry CreateEntry(string entryName, string filePath)
        {
            if (_mode == EPFArchiveMode.Read)
            {
                throw new InvalidOperationException("Unable to create any entry in read-only mode");
            }

            if (_entryDictionary.ContainsKey(entryName))
            {
                throw new ArgumentException($"Entry '{entryName}' already exists.");
            }

            var newEntry = new EPFArchiveEntryForCreate(this, entryName, filePath);

            AddEntry(newEntry);

            ModifiedEntriesNo++;

            return(newEntry);
        }