private void ExtractFileContents() { string filename = mSaveFileNameTextBox.Text; int result = ARMaxNativeMethods.InitMaxSave(); if (result != 0) { throw new Exception("Could not load initialize ARMax DLL!"); } result = ARMaxNativeMethods.LoadSave(filename); if (result != 0) { throw new Exception("Could not load file:" + filename); } StringBuilder rootDirName = new StringBuilder(256); ARMaxNativeMethods.GetRootDir(rootDirName, 256); rootDirName.Append("\\"); string dirName = ".\\UnpackFolder_" + rootDirName.ToString(); if (Directory.Exists(dirName)) { Directory.Delete(dirName, true); } Directory.CreateDirectory(dirName); int numFiles = ARMaxNativeMethods.NumberOfFiles(); // show the files in the list box for (int i = 1; i < numFiles + 1; i++) // there is no '0'th file { try { result = ARMaxNativeMethods.ExtractAFile(i, dirName); if (result != 0) { Console.Error.Write("'ARMaxNativeMethods.ExtractAFile' Failed; code = {0}", result); } } catch (Exception exc) { Console.Error.WriteLine("Error calling 'ARMaxNativeMethods.GetRootDir()' LastError:{0}\n{1}", System.Runtime.InteropServices.Marshal.GetLastWin32Error() , exc.Message ); } } ARMaxNativeMethods.FreeMaxSave(); }