I am not very familiar with the OpenFileDialog
class, but am using it to select a file and open the file in a C# winform app. This is my syntax, and when it hits the open line it has the correct filename, but it throws a debug error of System.Runtime.InteropServices.COMException: The server threw an exception
RPC Info: Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)
and if memory serves, that is one of the most generic messages you can get. Syntactically is this set-up properly? Or how can I achieve my .xlsx file to be opened?
OpenFileDialog fd = new OpenFileDialog();
fd.Title = "Select The File To Open";
fd.Filter = "Excel Files|*.xlsx";
fd.InitialDirectory = @"C:\";
if (fd.ShowDialog() == DialogResult.OK)
{
Excel.Application xlsApp = new Excel.Application();
try
{
Workbook wb = xlsApp.Workbooks.Open(fd.FileName);
MessageBox.Show("The file was opened");
}
catch (Exception grrr) { MessageBox.Show(grrr.ToString()); }
}