Hi Mike
I have changed the code using Server.MapPath but to no avail.
Prints the Adobe PDF document to the default local printer
(I am running this localhost). I Have not run it on the server yet.
What confuses me is
1. All the documents to be printed are in the same directory -
The application directory - so the authorities to the objects
should all be the same. All objects have the same Access
properties.If it can find the PDF document then why can't
it find the .doc and .xls documents.
2. Each of the applications starts up. Adobe, Excel, Word.
I can see the application start in the task manager.
This suggests that both Excel and Word are trying to
perform the required action but failing;
3. The catch throws an Access Denied exception in response
to the error.
(The catch does not throw an exception if there is an existing
instance of the Word or Excel application running. The page
just hangs and no exception is thrown).
I have a small piece of code to forceably kill the process if
it does not end itself. In both the Excel and WORK instances
the code throws an exception
No process is associated with this object
try
{
if (myProcess.HasExited == false)
{
myProcess.Kill();
}
}
catch (Win32Exception ex)
{
label1.Text = label1.Text + "<br><br><br>" + "Cannot Kill Process :
Error Code = " +
ex.ErrorCode + "<br>" + "Base Exception Is " +
ex.GetBaseException() + "<br>" + "Inner Exception Is " +
ex.InnerException + "<br><br><br>";
}
Surely if the process has started then there must be a process
associated with the process object !!!!
I am confused.
best regards
Iain
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++
Code
-------
try
{
myProcess.StartInfo.FileName = Server.MapPath (PFileName);
myProcess.StartInfo.Verb = "Print";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
myProcess.WaitForExit(20000);
}
catch (Win32Exception ex)
{
if(ex.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
label1.Text = label1.Text + "<br><br><br>" + "Path Error : " +
ex.Message + "<br><br><br>";
}
else
if (ex.NativeErrorCode == ERROR_ACCESS_DENIED)
{
label1.Text = label1.Text + "<br><br><br>" + "Permission Error : "
+ ex.Message + "<br><br><br>";
}
else
{
label1.Text = label1.Text + "<br><br><br>" + "Unknown Error : " +
ex.Message + "<br><br><br>";
}
}