How to...

  • Thread starter Jacek Jurkowski
  • Start date
J

Jacek Jurkowski

Having file name:

1) Open file using default external Windows application.
2) Wait for external application to modify the file.

I did that like below but for some reasons that code
does not always work properly:

-------------------------------------------------------

[loading from SQLServer table into c:\temp.xml" code]

fileName = "c:\\temp.xml";
Process proces = Process.Start(fileName);

while(!Process.HasExited)
{
Application.DoEvents();
}

or

process.WaitForExit();

[saving into SQLServer table from c:\temp.xml code]

File.Delete(fileName);
---------------------------------------------------------

In that case the process exits imediatelly after running IE
to open an xml and code goes into Delete section on open
file ...

How to do that in other (proper) way?
 
G

Guest

The problem with executing a file associated with an executable is that the
application that is run is free to do whatever if wants to edit the file,
including passing the file to an existing instance of the same app and
closing the process that you started without doing anything with the file.

There's no way to reliably do what you want to do without knowing more about
the application that loads the XML file (in your case).
 
J

Jacek Jurkowski

Thanks for Your explanations ...

Jacek


Peter Ritchie said:
The problem with executing a file associated with an executable is that
the
application that is run is free to do whatever if wants to edit the file,
including passing the file to an existing instance of the same app and
closing the process that you started without doing anything with the file.

There's no way to reliably do what you want to do without knowing more
about
the application that loads the XML file (in your case).

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#


Jacek Jurkowski said:
Having file name:

1) Open file using default external Windows application.
2) Wait for external application to modify the file.

I did that like below but for some reasons that code
does not always work properly:

-------------------------------------------------------

[loading from SQLServer table into c:\temp.xml" code]

fileName = "c:\\temp.xml";
Process proces = Process.Start(fileName);

while(!Process.HasExited)
{
Application.DoEvents();
}

or

process.WaitForExit();

[saving into SQLServer table from c:\temp.xml code]

File.Delete(fileName);
---------------------------------------------------------

In that case the process exits imediatelly after running IE
to open an xml and code goes into Delete section on open
file ...

How to do that in other (proper) way?
 

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

Top