Open File

pendragon

Well-known member
Joined
Aug 20, 2003
Messages
207
Location
Cambridgeshire
Hi All

Hope you can help, I am trying to open word and pass the document to open as a string.

If the string is c:\bin\calllog.doc then it opens fine but if the path includes spaces then word says it cant find the document

ie c:\Documents and Setting\Administrator\My Documents\CallLog.doc

Can some one please tell me what it is I am forgetting to do :confused:

this is the code I am using

PHP:
Process MyProcess;

string ProgramToRun = "WINWORD.EXE";
string DocumentToOpen = dataaccess.rowActions[dataaccess.colACTAttachmentPath].ToString() + dataaccess.rowActions[dataaccess.colACTAttachment].ToString();

MessageBox.Show(DocumentToOpen);

MyProcess = Process.Start(ProgramToRun, DocumentToOpen);
MyProcess.WaitForInputIdle();
MyProcess.Close();
MyProcess.Dispose();

Thank you for your help
 
By the way, you can simply pass the file path to Process.Start for a registered file type to open the file with the default program. Its not a big deal here, but if you had had to provide the full path to WinWord and didnt know it on another machine it would be an issue:[VB]Process.Start("C:\\MyDocument.doc")[/VB]
 
Back
Top