付録A - ライセンスファイルの圧縮およびエンコーディングPowerShellヘルパー機能
このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。
function ConvertTo-CompressedBase64String { CmdletBinding() Param ( Parameter(Mandatory) ValidateScript( { if (-Not ($_ | Test-Path) ) { throw "The file or folder $_ does not exist" } if (-Not ($_ | Test-Path -PathType Leaf) ) { throw "The Path argument must be a file. Folder paths are not allowed." } return $true }) string $Path ) $fileBytes = System.IO.File::ReadAllBytes($Path) System.IO.MemoryStream $memoryStream = New-Object System.IO.MemoryStream $gzipStream = New-Object System.IO.Compression.GzipStream $memoryStream,(IO.Compression.CompressionMode::Compress) $gzipStream.Write($fileBytes, 0, $fileBytes.Length) $gzipStream.Close() $memoryStream.Close() $compressedFileBytes = $memoryStream.ToArray() $encodedCompressedFileData = Convert::ToBase64String($compressedFileBytes) $gzipStream.Dispose() $memoryStream.Dispose() return $encodedCompressedFileData } ConvertTo-CompressedBase64String -Path .\license.xml