views:

12

answers:

1

In an OpenFileDialog, the user can enter the address of the SharePoint site and select a document in the document library. I need to provide check-in/check-out integration for SharePoint documents. Is there any way to determine if the file is stored in a SharePoint document library?

Thanks in advance!

A: 

After the dialog returns, you can check the value of the selected file. If there's a value, they probably selected a file. You can validate that a file was actually selected by attempting to open the file.

Start here: http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx

Cornelius J. van Dyk
How does knowing that a file is selected help me figure out if the file is stored in a SharePoint site?
AlexC
Once you have a URI value, you can strip off the document name and attempt to open a SPSite object. If it succeeds, your document is stored in a SharePoint site. Try this:
Cornelius J. van Dyk
using(SPSite site = new SPSite("http://YOUR_URL_HERE")){ if (site != null) { //Process check in/out } else { //Not a SharePoint site. }}The trick is that the SPSite object is smart enough to deduce if your URL contains a valid path to a SharePoint site collection at it's beginning. If it does, it'll create the object. If not, you're not in SharePoint.
Cornelius J. van Dyk