Tony Testa posted on April 20, 2009 15:09

Yet another post thats better late than never.  Back in Feb I was lucky enough to present at the Microsoft Silverlight Firestarter event and we have a GREAT turnout, over 100+ people attended and I of course presented on integrating Silverlight with SharePoint.

Yet another interesting MSDN forum post I answered.  A user asked how they could programmatically determine the installation directory of SharePoint.  After multiple searches on the web, etc. I stumbled on the answer….read the registry!

Here is some sample code (i havent actually tested this code but the logic is sound):

using Microsoft.Win32;
RegistryKey masterKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Office Server\\12.0");
if (masterKey == null)
   Console.WriteLine ("Null Masterkey!");
   Console.WriteLine ("MyKey = {0}", masterKey.GetValue ("InstallPath"));


the only issue I see here is that depending your farm (a 5 server farm for example), is if you install SharePoint in a different directory on each web front end.  In that case, depending on what server the request gets processed, you may get a different location that if you run the same request on a different WFE where the install directory was different. 

Honeslty I've never run into a case where the install directory was different on each WFE since most WFE's mirror each other, just thought I would throw it out there to you as well as the fact that it would just be bad practice to have the WFE’s use different install directories.

Another user responded to the post and said you could do it using the SPUtility class’s GetGenericSetupPath method, which seems a bit more logical and using the SharePoint API.

using Microsoft.SharePoint.Utilities;
string featurePath = SPUtility.GetGenericSetupPath("12");

Posted in:   Tags: , ,

On the MSDN forums I answered a blog posting about how to update some values of a user profile.  I’ve answered this question more than a few times so I threw up this posting about it.

Here is some basic code to achieve this (its actually from MSDN but I’ve written the same code enough times just couldn’t find it offhand)

using (SPSite site = new SPSite("http://servername"))
    ServerContext context = ServerContext.GetContext(site);
    UserProfileManager profileManager = new UserProfileManager(context);
    string sAccount = "domainname\\username";
    UserProfile u = profileManager.GetUserProfile(sAccount);
    u[PropertyConstants.PictureURL].Value = "SOME URL";



Be sure to check out MSDN for the members of the PropertyConstants.

Tony Testa posted on March 15, 2009 03:48

A few days late but I finally got to posting my code/slides for the March Office Geeks we had on March 10th.  I've zipped up the code that I went over during the presentation which will show you some of the ways you can incorporate MS AJAX and jQuery into your SharePoint sites.

SharePoint has issues with using keywords "today" and "my". Due to this issue, a few workarounds have to be done to achieve the "Today" functionality. See steps below to create a "rolling" calendar view that shows calendar entries for X number of months out.

FYI, MS has on their site a list of some advanced filter options that I would recommend if your looking to do filtering, check it out, it helped me a lot


  1. Go to your Calendar list and create a column named "Today" and select "single line of text" and do not add it to the default view. This column is merely a placeholder column to achieve "Today" functionality that we can use to filter views
  2. Create a new column named "RollingDateFilter", make it a "calculated column"
    1. Set the calculated formula to "=AND(MONTH([Start Time])>=MONTH(Today),MONTH([Start Time])<=MONTH(Today)+2)"
      1. This formula will be used to filter our list
      2. If you want to see more months out, change 2 in the formula above to the # of months you want to see.
    2. Be sure to set the data type returned to "Yes/No"
    3. Be sure to uncheck "add to default view"
    4. IF you need to change the formula later, you will first have to recreate the "Today" column in step 1, modify the formula, save the formula, then delete the "Today" column.
  3. Delete the "Today" column
    1. This is needed for the "Today" value to be properly parsed in the above formula
    2. IF the "Today" column is not deleted, the formula using "Today" WILL NOT PROCESS CORRECTLY
  4. Create a new View and base it off the "All Events" view
    1. Select the columns you want to show, just accept the defaults
    2. Scroll down to the Filter section
    3. Set the filter to "RollingDateFilter" and set "is equal to" and set "Yes"
    4. Save the view
    5. You should now have a view that only shows 2 months out.
  5. Go to the homepage that has your un-filtered calendar view


    1. Edit the webpart
    2. Switch the view to "2MonthRolling" and save the changes

The results below

Posted in: Sharepoint  Tags: , ,
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017 Tony Testa's World