コード例 #1
0
        /// <summary>
        /// Writes the file represented by the given file stream to the given path.
        /// </summary>
        /// <remarks>
        /// This method writes the given data as a file at the given path. If the file
        /// already exists the user is prompted to overwrite the file.
        /// </remarks>
        /// <param name="p_strPath">The path where the file is to be created.</param>
        /// <param name="p_fstData">The data that is to make up the file.</param>
        /// <returns><c>true</c> if the file was written; <c>false</c> if the user chose
        /// not to overwrite an existing file.</returns>
        public virtual bool GenerateDataFile(string p_strPath, FileStream p_fstData)
        {
            string strInstallFilePath = p_strPath;

            if (!Directory.Exists(Path.GetDirectoryName(strInstallFilePath)))
            {
                TransactionalFileManager.CreateDirectory(Path.GetDirectoryName(strInstallFilePath));
            }
            else
            {
                if (!TestDoOverwrite(p_strPath))
                {
                    return(false);
                }
            }
            TransactionalFileManager.WriteFileStream(strInstallFilePath, p_fstData);
            InstallLog.AddDataFile(Mod, p_strPath);
            return(true);
        }