I have below C# code which i want to run in UiPath using invoke code activity but the program is not compiling and giving errors. Any help would be great.
This program is to merge files.
var allCsv = Directory.EnumerateFiles("C:\Users\Documents\UiPath\Files1", "*.csv", SearchOption.TopDirectoryOnly);
string[] header =
{
File.ReadLines(allCsv.First()).First(l => !string.IsNullOrWhiteSpace(l))
};
// Get CSV Data
var mergedData = allCsv.SelectMany(csv => File.ReadLines(csv).SkipWhile(l => string.IsNullOrWhiteSpace(l)).Skip(1));
// skip header of each file
File.WriteAllLines("C:\Users\Documents\UiPath\test.xlsx", header.Concat(mergedData));
Backslash is recognized as escape character in C#. So we need to escape itself if we handle it as literal. Or if we use @ like @"xxx", we can handle backslash as literal even if not escape.
Please also see the following document - section2.