/// <summary> /// Deletes a file from the MPQ. CALL openMPQ(); after this !! /// </summary> /// <param name="mpqHandle">Handle of the MPQ file.</param> /// <param name="fileName">Filename to delete</param> /// <param name="mpqFileName">MPQ file location (open for modification)</param> /// <param name="mpqCloseFunc">Function to close the MPQ file</param> /// <returns></returns> public static bool deleteFile(uint mpqHandle, string fileName, string mpqFileName, Action mpqCloseFunc) { uint hFile = 0; if (!Storm.SFileOpenFileEx(mpqHandle, fileName, 0, ref hFile)) { throw new System.IO.FileNotFoundException("File not found in the MPQ: " + fileName); } if (hFile != 0) { Storm.SFileCloseFile(hFile); } System.Threading.Thread.Sleep(1000); mpqCloseFunc(); int modMPQ = Storm.MpqOpenArchiveForUpdate(mpqFileName, Storm.MOAU_OPEN_EXISTING, uint.MaxValue); if (modMPQ != 0) { Storm.MpqDeleteFile(modMPQ, fileName); } else { throw new System.IO.IOException("ErrCode: " + Convert.ToString(Marshal.GetLastWin32Error())); } Storm.MpqCloseUpdatedArchive(modMPQ, 0); return(true); }