Ahmed Emad Ahmed Emad - 1 year ago 87
C# Question

How do I use Process.Start to open a word file (Path with Spaces)?

The file is in the directory but the spaces cause this error:

string outfile = @"C:\Users\hp\Desktop\New folder (4)\outFile.doc";
Process.Start("WINWORD.EXE", outfile);

Shows me this message


Answer Source

Provided that Winword.exe is your default application for Word documents, all you need is to specify your document's path in the process Filename property as follows

        Process p = new Process();
        p.StartInfo.FileName = @"C:\Users\Someone\Documents\Path With Spaces\Word.docx";

Tested in Visual Studio 2015 Community Edition

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download