1

I'm creating a .net webform to launch a .exe file located on the user's computer. The .exe accepts parameters, and one of the parameters i'd like to pass to it is an xml file that my webform dynamically generates. I've used XMLWriter to generate the xml, but I need to pass the created XML path to the following call method:

using (Process Ansur = Process.Start(startInfo, "/r " XML File Path ));

I'm lost on how to go about temporarily saving the XML from the XMLWriter in memory, and getting a filepath to pass as a parameter.

I wanted to go about this temporary since then I'd reduce the need to create and modify a XML document on the server side, which I'd assume reduces the need to communicate from the server.

Please help!

chickenricekid
  • 390
  • 4
  • 19

2 Answers2

2

Have a look at this answer, it explains how you can obtain a statistically unique temp file path. You can then open a filestream and copy the contents of your memorystream to the file like memory.CopyTo(file)

Community
  • 1
  • 1
Jan Garcia
  • 46
  • 1
  • 4
0

1) Find you application path See here

2) Use either DateTime Ticks.toString() or as jan's pointed to use a GUID. I personally like ticks better since it's sequential instead of random chars that guid offers.

3) Once created execute you exe with the file as the parameter.

Community
  • 1
  • 1
Zuzlx
  • 1,246
  • 14
  • 33