Another possible option - just copy the file using a process in C#, create a process to copy the file from xls to xlsx. No fuss, no muss. This is in .Net Core 6.0 and o365.
Ultimately, the string you are running in the process (aka command prompt) should look similar to this:
"C:\Program Files (x86)\Microsoft Office\root\Office16\excelcnv.exe"
-oice "\Share\Folder\Cash.xls" "\Share\Folder\Cash.xlsx"
public static class Xls2XlsxCmdProcess
{
public static string processDirectory = @"C:\Program Files (x86)\Microsoft Office\root\Office16\";
public static void ExecuteCommandSync(string pathToExe, string command)
{
var procStartInfo = new ProcessStartInfo(pathToExe, command)
{
WorkingDirectory = processDirectory,
CreateNoWindow = false,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true
};
var proc = new Process { StartInfo = procStartInfo };
proc.Start();
//proc.StandardInput.WriteLine(password);//If the app that requires a password or other params, they can be added here as a string.
proc.StandardInput.Flush();
// Get the output into a string
string result = proc.StandardOutput.ReadToEnd();
string error = proc.StandardError.ReadToEnd();
Console.WriteLine(result);
Console.WriteLine(error);
}
}
To call it, specify all your params, your working directory, and you're off to the races!!!
string baseFolder = @"\\Share\folder\";
string fileNameCash = "Cash.xls";
string fileNameCashOutput = "Cash.xlsx";
//Create cash as xlsx files (for ease of use with EPPlus4)
string pathToExe = @"C:\Program Files (x86)\Microsoft Office\root\Office16\excelcnv.exe";//Path to office XLS to XLSX Conversion Tool for o365 - You can find a similar version by searching for the excelcnv.exe within "C:\Program Files (x86)\Microsoft Office" folder.
string commandFormat1 = string.Format(@"""{0}"" -oice ""{1}{2}"" ""{3}{4}"" ",pathToExe, @BaseFolder, fileNameCash,@BaseFolder,fileNameCashOutput);
Xls2XlsxCmdProcess.ExecuteCommandSync(pathToExe, string.Format(commandFormat1));