public void DeleteEntry(int Index)
{
try
{
FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
DebugOutput.PrintLn("Searching TOC...");
int f = FindTOC();
if (f == -1)
return;
DebugOutput.PrintLn("Found TOC, deleting line...");
MemoryStream m = DecompressEntry(f, fs);
fs.Close();
FileEntryStruct e = Files[Index];
string toc = Encoding.UTF8.GetString(m.ToArray(), 0, (int)m.Length);
string file = e.FileName + "\r\n";
toc = toc.Replace(file, "");
DebugOutput.PrintLn("Replacing TOC...");
ReplaceEntry(Encoding.ASCII.GetBytes(toc), f);
DebugOutput.PrintLn("Deleting Entry from Filelist...");
List<FileEntryStruct> l = new List<FileEntryStruct>();
l.AddRange(Files);
l.RemoveAt(Index);
Files = l.ToArray();
Header.FileCount--;
DebugOutput.PrintLn("Rebuilding...");
ReBuild();
DebugOutput.PrintLn("Done.");
}
catch (Exception ex)
{
DebugOutput.PrintLn("ERROR\n" + ex.Message);
}
}