public WriteAllBytes ( string path, byte contents ) : void | ||
path | string | The file to write to. |
contents | byte | The bytes to write to the file. |
Результат | void |
/// <summary> /// Get the ReadMe file path if it exists. /// </summary> /// <param name="p_strFileName">The mod file name.</param> /// <param name="p_intReadmeFile">The index of the readme file to get.</param> public string GetModReadMe(string p_strModName, string p_strFileName) { string strReadMe = String.Empty; if (m_dicReadMeFiles.ContainsKey(p_strModName)) { string strModReadMeFile = p_strModName + ".7z"; strModReadMeFile = Path.Combine(m_strReadMePath, strModReadMeFile); if (File.Exists(strModReadMeFile)) { PurgeTempFolder(); Archive arcFile = new Archive(strModReadMeFile); byte[] bteData = arcFile.GetFileContents(p_strFileName); if ((bteData != null) && (bteData.Length > 0)) { TxFileManager tfmFileManager = new TxFileManager(); string strReadMeFile = Path.Combine(ReadMeTempPath, p_strFileName); tfmFileManager.WriteAllBytes(strReadMeFile, bteData); return strReadMeFile; } } } return strReadMe; }
/// <summary> /// Verifies if the readme file exists in the archive and saves it to the ReadMe folder. /// </summary> /// <param name="p_strArchivePath">The path to the mod archive.</param> public bool VerifyReadMeFile(TxFileManager p_tfmFileManager, string p_strArchivePath) { try { Archive arcFile = new Archive(p_strArchivePath); List<string> lstFiles = GetFileList(arcFile, true); string strReadMePath = m_strReadMePath; string strFileName = String.Empty; string strReadMeFile = String.Empty; string strModFile = Path.GetFileName(p_strArchivePath); string strArchiveFile = Path.GetFileNameWithoutExtension(strModFile) + ".7z"; byte[] bteData = null; PurgeTempFolder(); for (int i = 0; i < lstFiles.Count; i++) { strFileName = lstFiles[i].ToString(); if (Readme.IsValidReadme(strFileName)) { bteData = arcFile.GetFileContents(lstFiles[i]); if (bteData.Length > 0) { strReadMeFile = Path.GetFileName(strFileName); strReadMePath = Path.Combine(ReadMeTempPath, strReadMeFile); p_tfmFileManager.WriteAllBytes(strReadMePath, bteData); } } } string[] strFilesToCompress = Directory.GetFiles(ReadMeTempPath, "*.*", SearchOption.AllDirectories); if (strFilesToCompress.Length > 0) if (CreateReadMeArchive(strArchiveFile, strFilesToCompress)) { for (int i = 0; i < strFilesToCompress.Length; i++) { strFilesToCompress[i] = Path.GetFileName(strFilesToCompress[i]); } m_dicReadMeFiles.Add(Path.GetFileNameWithoutExtension(strArchiveFile), strFilesToCompress); } } catch { return false; } return true; }