View Single Post
Old 09-19-2006   #1 (permalink)
Mark


 
 

Why does get-content on a text file remove crlf when cast to a string?


Given the following:

function doWork($fileContent)
{
write-output $fileContent
}

gci . -i AssemblyInfo.cs -r | % { doWork (gc $_.FullName) }

will result in the contents of all AssemblyInfo.cs files being dumped to the
screen. However, this

function doWork([string]$fileContent)
{
write-output $fileContent
}

gci . -i AssemblyInfo.cs -r | % { doWork (gc $_.FullName) }

results in all crlf'ds being removed.

I am trying to update version information and I have a reg-ex in 'doWork'
that does the updates but the problem is that whenver the results of
get-contents is processed as a string, all the crlf information vanishes
which results in corrupted files?

What am I doing wrong?

thanks
-mark

--
-mark

My System SpecsSystem Spec