coffeecoder coffeecoder - 3 years ago 74
C# Question

How to open a document from SharePoint using the Client Object Model

I am trying to recreate SharePoint's open item behaviour from a client app.

The behaviour I am trying to achieve is to give my application a URL to an item in SharePoint and for the item load in it's native editor with the SharePoint options available such as check in, check out.

I have been able to use Process.Start and pass a URL to a word document on SharePoint which will open Internet Explorer's download list, and when I open the item from there, it opens in Word correctly as if I have opened it from SharePoint, but I don't want the download window to appear at all.

Is it possible to recreate this behaviour and open an item directly from SharePoint without seeing the download list window first using the Client Object Model?

Answer Source

I have found a solution to this.

By default, when you use Process.Start with a URL it launches a web browser, which is normally reasonable enough behaviour.

In this case, bypassing the web browser is the desired behaviour, and the way around that is to specific the FileName Property of the StartInfo object being given to Process with the process to start.

In the case of a word document this is "winword.exe".

If you need to dynamically determine what the filename should be, see this answer:
Is an Application Associated With a Given Extension?

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