I’m invoking this below code using Invoke Code activity by setting Language as CSharp. Please find the code and error details below. Kindly help me to fix this issue.
using System;
using System.Diagnostics;
class Program
{
static void Main(String args)
{
// Path To SpreadsheetCompare.exe And Excel files To compare
string spreadsheetComparePath = @“C:\Program Files\Microsoft Office\root\Office16\DCF\SpreadsheetCompare.exe”;
string file1Path = @“C:\path\to\file1.xlsx”;
string file2Path = @“C:\path\to\file2.xlsx”;
try
{
// Start SpreadsheetCompare.exe process In the background
Process process = new Process();
process.StartInfo.FileName = spreadsheetComparePath;
process.StartInfo.Arguments = $"\"{file1Path}\" \"{file2Path}\"";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
// Check If SpreadsheetCompare.exe exited successfully
if (process.ExitCode == 0)
{
Console.WriteLine("Comparison completed successfully.");
}
else
{
Console.WriteLine($"Comparison failed. Exit code: {process.ExitCode}");
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
}
No compiled code to run
error CS1001: Identifier expected At line 1
error CS1001: Identifier expected At line 2
error CS1513: } expected At line 2
error CS1022: Type or namespace definition, or end-of-file expected At line 40
error CS0118: ‘System’ is a namespace but is used like a type At line 1
error CS0210: You must provide an initializer in a fixed or using statement declaration At line 1
error CS0118: ‘System.Diagnostics’ is a namespace but is used like a type At line 2
error CS0210: You must provide an initializer in a fixed or using statement declaration At line 2