将命令修改完后,直接粘贴到powershell窗口,点击回车即可进行切割
$filePath = "D:\test\zb_content_1.txt"
$outputPath = "D:\test\"
$chunkSize = 1GB
$bufferSize = 1MB
$fileStream = [System.IO.File]::OpenRead($filePath)
$reader = New-Object System.IO.BinaryReader($fileStream)
$chunkIndex = 1
try {
while ($true) {
$chunkFilePath = Join-Path $outputPath "zb_content_1_$chunkIndex.txt"
$chunkIndex++
$writer = New-Object System.IO.BinaryWriter([System.IO.File]::OpenWrite($chunkFilePath))
try {
$bytesLeft = $chunkSize
while ($bytesLeft -gt 0) {
$buffer = $reader.ReadBytes([Math]::Min($bytesLeft, $bufferSize))
if ($buffer.Length -eq 0) {
break
}
$writer.Write($buffer)
$bytesLeft -= $buffer.Length
}
} finally {
$writer.Close()
}
if ($bytesLeft -gt 0) {
break
}
}
} finally {
$reader.Close()
}