There are instances where you write to a file (say XML/Text file/word) fo debugging/testing etc.In those scenarios,your program finishes writing to the file and then you open the file manually in the application(IE/Notepad/Microsoft word) to see what the program has written in that file.You can actually launch that application after you finish writing to that file from with in the program making the whole process quick.The file opens in its default application right after you finish debugging without you needing to manually open it.
The steps:- (2 lines):-
a) Include the namespace:-
using System.Diagnostics;
using System.Diagnostics;
b) Start the process for the saved file:-
//
//Code to save the file
//
// Following line would open the saved file in its default application
Process.Start("SavedFullFilePath");
Example:-
// Code to save the file
XmlDocument Xdoc = new XmlDocument();
string folderPath = @"C:\Ashish\";
string upload = folderPath + "2007.docx";
string savename = folderPath + "WordPackage.xml";
ZipPackage zipPackage = null;
byte[] packageData = null;
Stream stream;
packageData = GetBytesFromFile(upload);
stream = new MemoryStream(packageData);
if (stream != null)
zipPackage = GetZipPackageFromStream(stream);
Xdoc = RRD.DSA.SCP.OfficeAssembler.WordToXyXmlAssembler.ConvertToXyXml(zipPackage);
Xdoc.Save(savename); // Following line would open the saved file in its default application (Internet explorer)
Process.Start(strSave);
XmlDocument Xdoc = new XmlDocument();
string folderPath = @"C:\Ashish\";
string upload = folderPath + "2007.docx";
string savename = folderPath + "WordPackage.xml";
ZipPackage zipPackage = null;
byte[] packageData = null;
Stream stream;
packageData = GetBytesFromFile(upload);
stream = new MemoryStream(packageData);
if (stream != null)
zipPackage = GetZipPackageFromStream(stream);
Xdoc = RRD.DSA.SCP.OfficeAssembler.WordToXyXmlAssembler.ConvertToXyXml(zipPackage);
Xdoc.Save(savename); // Following line would open the saved file in its default application (Internet explorer)
Process.Start(strSave);