Skip to content

Commit

Permalink
use filestream over streamwriter
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Dover authored and Scott Dover committed Jan 12, 2024
1 parent a589058 commit 9b1bbcd
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions client/src/connection/itc/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,23 @@ class SASRunner{
$objFile = $this.objSAS.FileService.AssignFileref("outfile", "DISK", $filePath, "", [ref] $fileRef)
$objStream = $objFile.OpenBinaryStream(1);
[Byte[]] $bytes = 0x0
$endOfFile = $false
$byteCount = 0
$outStream = [System.IO.StreamWriter] $outputFile
do
{
$objStream.Read(1024, [ref] $bytes)
$outStream.Write([System.Text.Encoding]::UTF8.GetString($bytes))
$endOfFile = $bytes.Length -lt 1024
$byteCount = $byteCount + $bytes.Length
} while (-not $endOfFile)
$objStream.Close()
$outStream.Close()
$this.objSAS.FileService.DeassignFileref($objFile.FilerefName)
$outStream = New-Object System.IO.FileStream($outputFile, [System.IO.FileMode]::OpenOrCreate, [System.IO.FileAccess]::Write)
try {
do
{
$objStream.Read(1024, [ref] $bytes)
$outStream.Write($bytes, 0, $bytes.length)
$endOfFile = $bytes.Length -lt 1024
$byteCount = $byteCount + $bytes.Length
} while (-not $endOfFile)
} finally {
$objStream.Close()
$outStream.Close()
$this.objSAS.FileService.DeassignFileref($objFile.FilerefName)
}
Write-Host "${LineCodes.ResultsFetchedCode}"
}
Expand Down

0 comments on commit 9b1bbcd

Please sign in to comment.