0

I am using the following powershell script to copy a text file from one location to another and then encode it so that it can be imported using a SQL bulk copy. The source file is encoded as UCS-2 Little Endian.

gc "\\SourceServer\Share\Person.txt" | Out-File -encoding ASCII \\dbserver\share\DataFlag\Person.txt

Can the same action be done in C# without using the powershell script?

leppie
  • 115,091
  • 17
  • 196
  • 297
Hoody
  • 3,361
  • 9
  • 45
  • 55

1 Answers1

1

As explained here, there is no direct support for UCS-2 in C# But it should be possible to read the file using a StreamReader with UTF-16 and compensate the differences by some additional byte-tweaking. Takes some research, though.

Community
  • 1
  • 1
Axel Kemper
  • 10,544
  • 2
  • 31
  • 54