Source file for preview is not available

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a simple batch file that takes 3 args to create a .pdf file, and
then view that PDF file using on the Microsoft's Web Browser control
(AxSHDocVw.AxWebBrowser):

{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName =@"C:\test-fo.bat";
p.StartInfo.WindowStyle= System.Diagnostics.ProcessWindowStyle.Hidden ;
string s1= @"C:\2.xml";
string s2= @"C:\ftid-fo.xsl";
string s3= @"C:\FO1.pdf";

p.StartInfo.Arguments= "\"" + s1 + "\"" + " " + "\"" + s2 + "\"" + " " +
"\"" + s3 + "\"";
p.Start();
p.Close();

string strFile = s3;
XMLBrowser.Navigate(strFile ,ref objNull,ref objNull,ref objNull,ref
objNull);
}

When I call the above for the first time... it gives an error :"Source file
for preview is not available". This only happens for the first time! I can
call the same code (after the first instance) without any errors and get the
preview of the generated file.

Is there any property/setting that i am missing related to the Process class?
Please suggest.

Thanks.
 
Gaurav,

You need to wait for the process to end. You should make a call to
WaitToExit on the Process instance you create so that you know the process
completes before you tell the web browser to load it.

Hope this helps.
 
Bingo!

Thanks Nicholas :)

Nicholas Paldino said:
Gaurav,

You need to wait for the process to end. You should make a call to
WaitToExit on the Process instance you create so that you know the process
completes before you tell the web browser to load it.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gaurav said:
I am using a simple batch file that takes 3 args to create a .pdf file, and
then view that PDF file using on the Microsoft's Web Browser control
(AxSHDocVw.AxWebBrowser):

{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName =@"C:\test-fo.bat";
p.StartInfo.WindowStyle= System.Diagnostics.ProcessWindowStyle.Hidden ;
string s1= @"C:\2.xml";
string s2= @"C:\ftid-fo.xsl";
string s3= @"C:\FO1.pdf";

p.StartInfo.Arguments= "\"" + s1 + "\"" + " " + "\"" + s2 + "\"" + " " +
"\"" + s3 + "\"";
p.Start();
p.Close();

string strFile = s3;
XMLBrowser.Navigate(strFile ,ref objNull,ref objNull,ref objNull,ref
objNull);
}

When I call the above for the first time... it gives an error :"Source
file
for preview is not available". This only happens for the first time! I can
call the same code (after the first instance) without any errors and get
the
preview of the generated file.

Is there any property/setting that i am missing related to the Process
class?
Please suggest.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top