Tip #109 How to make a link that will open Sharepoint Workspace or SkyDrive Pro

Rate this item
(0 votes)

In my previous post I have been discussing a web part that should create a new library.The next thing we were asked was to create a link that will open Sharepoint WorkSpace or SkydrivePro

Just like this

 

 

It turned out that you need provide a very weird encoded link

Here is a link we have produced in our webpart

 

grvopen://http_58_47_47sp2010_47sites_47onenote_47test/5f594410_451d8c_454d0c_45af05_4500f60a0e1bea/101?OPENLIST

 

Grvopen stands for Groove (that was later renamed to Sharepoint WorkSpace and later to SkyDrive Pro)

The piece of code that does encoding is taken from Tatham Oddie

https://gist.github.com/tathamoddie/5858129

And is posted to his github

http://blog.tatham.oddie.com.au/

 

Here is a full code

 

// based on https://gist.github.com/tathamoddie/5858129
static string BuildGrooveUri(SPDocumentLibrary lib)
{
   
var libUrl  = SPUtility.ConcatUrls(lib.ParentWeb.Url, lib.RootFolder.Url);
   
const string grooveOpenUriTemplate = "grvopen://{0}/{1}/{2}?OPENLIST";
   
var uri = string.Format(
        grooveOpenUriTemplate,
        Encode(libUrl),
        Encode(lib.ID.ToString()),
        (
int)lib.BaseTemplate);
   
return uri;
}
 
static string Encode(string plain)
{
   
return plain
        .ToCharArray()
        .Select(c =>
char.IsLetterOrDigit(c) ? c.ToString() : "_" + ((int)c).ToString())
        .Aggregate(
"", (s, c) => s + c);
}

 

Enjoy!

 

http://mbakirov.wordpress.com/2013/07/25/how-to-make-a-link-that-will-open-sharepoint-workspace-or-skydrive-pro/

 

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.