.NETCore (modern) project, cannot write file with Windows-1252 encoding

Hello dear UiPath Experts,

I’m stuck to a simple problem.
We need to manipulate csv files with Windows-1252 encoding.
I want to do that well with up-to date .NETCore UiPath Project. The project is almost done so moving to .NetFramework 4.6 is not possible :frowning: .

With OOTB .NETCore, it’s not possible to manipulate Windows-1252.
For that, you have to add package System.Text.Encoding to your projet…

Problem is : I can add System.Text.Encoding to UiPath Project…
But this dependency is red-flagged in Project view… And so on I cannot add System.Text.Encoding to namespace section.

What’s wrong ? How to add properly this dependency, and fix this issue ?

Kind regards,
Alex

2 Likes

I cannot upload any photo or .zip file :frowning:

How to reproduce:

  1. Create new project with Compatibility = Windows, Language = VB
  2. Add Write Text File activity
  3. On properties pane:
    Encoding = “Windows-1252”
    Text = “Hello”
    Filename = “Test.txt”
  4. Run or Debug, and you will see :

Write Text File: One or more errors occurred. (‘Windows-1252’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’)) (‘Windows-1252’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’)) (‘Windows-1252’ is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter ‘name’))

3 Likes

Hi,

Can you try to call the following using InvokeMethod activty just before WriteTextFile, as the following post?

System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance)

Main.xaml (4.7 KB)

Regards,

6 Likes

Hi Yoichi,

Thank you very much ! This is a very efficient solution, wow !

Kind regards,
Alex

ありがとうございました。
また日本へ旅行したいです。あなたの国、あなたの文化は素晴らしいです。
フランスで立ち往生しているAlexのサイン。

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.