I would suggest using rundll32.exe to invoke the shell32.dll with
OpenAs_RunDLL parameter.
Try this:
try
{
ProcessStartInfo pInfo = new ProcessStartInfo(@"C:
\list.dat");
Process.Start(pInfo );
}
catch (Win32Exception ex)
{
if (ex.ErrorCode == -2147467259)
//ErrorCode for No application is associated with
the specified file for
//this operation
{
ProcessStartInfo openWithInfo = new
ProcessStartInfo(@"C:\WINDOWS\system32\rundll32.exe");
openWithInfo .Arguments = @" C:\WINDOWS
\system32\shell32.dll, OpenAs_RunDLL .dat";
Process.Start(openWithInfo );
}
}
This woudl give you the Caution window displaying Openwith and Cancel
buttons.
I tried the code given by you, it is giving me error as
---------------------------
Application Error
---------------------------
An error occurred please contact the adminstrator with the following
information:
No application is associated with the specified file for this
operation
Stack Trace:
at
System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Wachovia.CIB.CDF.Shell.frmMain.newHelpMenuItem_Click(Object
sender, EventArgs e) in c:\projects\vcs\vss\onesource 1.2 plus\client
\src\client\wachovia.cib.cdf.shell\frmmain.cs:line 3501
at
Syncfusion.Windows.Forms.Tools.XPMenus.BarItem.OnItemClicked(EventArgs
args)
at Syncfusion.Windows.Forms.Tools.XPMenus.BarItem.PerformClick()
at
Syncfusion.Windows.Forms.Tools.XPMenus.MenuGrid.NotifyItem(BarItem
item)
at
Syncfusion.Windows.Forms.Tools.XPMenus.MenuGrid.HidePopup(PopupCloseType
popupCloseType)
at
Syncfusion.Windows.Forms.Tools.XPMenus.MenuGrid.ProcessItemClick(BarItem
item)
at
Syncfusion.Windows.Forms.Tools.XPMenus.MenuGrid.OnMouseUp(MouseEventArgs
e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at Syncfusion.Windows.Forms.ScrollControl.WmMouseUp(Message& msg)
at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg)
at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message&
msg)
at Syncfusion.Windows.Forms.Tools.XPMenus.MenuGrid.WndProc(Message&
m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
---------------------------
Abort Retry Ignore
---------------------------
What is OpenAs_RunDLL .dat. I am trying to open a .bak File.
regards,
Abhijeet Kumar.