CTA.WebForms.ProjectManagement.ProjectBuilder.WriteFileBytesToProject C# (CSharp) Method

WriteFileBytesToProject() public method

public WriteFileBytesToProject ( string relativePath, Array fileContent ) : void
relativePath string
fileContent Array
return void
        public void WriteFileBytesToProject(string relativePath, byte[] fileContent)
        {
            var fullPath = Path.Combine(_outputProjectPath, relativePath);
            try
            {
                CreateRelativeDirectoryIfNotExists(Path.GetDirectoryName(relativePath));

                if (File.Exists(fullPath))
                {
                    LogHelper.LogInformation(string.Format(FileAlreadyExistsLogTemplate, GetType().Name, fullPath));
                    // TODO: Maybe copy and store the old version of this file somehow?
                }

                using (FileStream stream = File.Create(fullPath))
                {
                    stream.Write(fileContent, 0, fileContent.Length);
                }

                LogHelper.LogInformation(string.Format(FileInfoWrittenLogTemplate, GetType().Name, fullPath));
            }
            catch (Exception e)
            {
                LogHelper.LogError(e, $"{Rules.Config.Constants.WebFormsErrorTag}Could not write file bytes to project (attempted to write to {fullPath}).");
            }
        }