public static void AddCbmFileToDict(Dictionary <int, TestFile> dictGeos64Zip, Dictionary <int, TestFile> toDict, int indexOfDiskDict, int indexOfCbmFile, int indexOfTestFile)
        {
            byte[]    bamBlock;
            byte[]    dirEntry     = null;
            ArrayList dirEntryList = new ArrayList();

            byte[] imageData     = dictGeos64Zip[indexOfDiskDict].data;
            int    imageDataType = 0; // sorry hard coded

            bamBlock     = DOSDisk.ReadBAMBlock(imageData, imageDataType);
            dirEntryList = DOSDisk.GetDirEntryList(bamBlock, imageData, imageDataType);
            dirEntry     = (byte[])dirEntryList[indexOfCbmFile - 1];

            string filename = (Core.ConvertPETSCII2ASCII(DOSDisk.GetFilename(dirEntry)));

            byte[]   fileData = DOSDisk.getFileData(dirEntry, imageData, imageDataType);
            string   newMD5   = Core.GetMD5Hash(fileData);
            TestFile tf       = new TestFile(filename, fileData, newMD5);

            tf.cleanCvtData    = tf.data;
            tf.CleanCvtDataMd5 = tf.dataMd5;

            toDict.Add(indexOfTestFile, tf);
        }
        static void ExtraxctFile(string imagePathFilename, int dirIndex, string asciiCbmFilename, string outPathFilename)
        {
            byte[]    bamBlock;
            byte[]    dirEntry     = null;
            ArrayList dirEntryList = new ArrayList();

            byte[] imageData     = DiskImageFile.ReadFile(imagePathFilename);
            int    imageDataType = DiskImageFile.GetImageDataType(imagePathFilename);

            bamBlock     = DOSDisk.ReadBAMBlock(imageData, imageDataType);
            dirEntryList = DOSDisk.GetDirEntryList(bamBlock, imageData, imageDataType);
            // by DirIndex
            if (dirIndex > 0)
            {
                dirEntry = (byte[])dirEntryList[dirIndex - 1];
            }
            else
            {
                if (asciiCbmFilename.Length > 0)
                {
                    bool found = false;
                    foreach (byte[] de in dirEntryList)
                    {
                        if (Core.ConvertPETSCII2ASCII(DOSDisk.GetFilename(de)) == asciiCbmFilename)
                        {
                            if (!found)
                            {
                                dirEntry = de;
                                found    = true;
                            }
                            else
                            {
                                throw new Exception("Filename is not unique!");
                            }
                        }
                    }
                    if (!found)
                    {
                        throw new Exception(String.Format("Filename {0} not found!", asciiCbmFilename));
                    }
                }
                else
                {
                    throw new Exception("No file specified");
                }
            }
            string filename = (Core.ConvertPETSCII2ASCII(DOSDisk.GetFilename(dirEntry)));

            if (DOSDisk.GetFileType(dirEntry) == 0)
            {
                throw new Exception(String.Format("File {0} is deleted!", filename));
            }
            byte[] fileData = DOSDisk.getFileData(dirEntry, imageData, imageDataType);
            if (outPathFilename != "")
            {
                DiskImageFile.WriteFile(fileData, outPathFilename);
            }
            else
            {
                DiskImageFile.WriteFile(fileData, filename);
            }
        }