You are currently browsing the monthly archive for March 2009.

I’m currently writing a web service on our SharePoint server to upload documents because one of our clients would like to migrate from a third party document management system to SharePoint.

This client would like to keep the legacy dates like the date of creation and the last modified date. After researching this, I still couldn’t find a way to do this. I noticed there are tools out there are able to do this so it is definitely possible.

So after some more trial and error I finally figured it out. And it wasn’t even that exotic, so I’d like to share how it is done.

When you’ve uploaded the file and checked it in you can change the dates with the following code:

public void UpdateFileDates(string siteCollectionUrl, string site, string file, DateTime created, DateTime modified)
    if (siteCollectionUrl == null) throw new ArgumentNullException("siteCollectionUrl");
    using (var spSite = new SPSite(siteCollectionUrl))
    using (var web = string.IsNullOrEmpty(site)
                        ? spSite.RootWeb
                        : spSite.OpenWeb(site))
        var spFile = web.GetFile(file);
        if (spFile != null)
            var item = spFile.Item;
            if (item != null)
                item["Created"] = created;
                item["Modified"] = modified;
                //When you do overwritecheckin the version doesn't change.
                spFile.CheckIn("", SPCheckinType.OverwriteCheckIn);

As you all probably know, Techdays 2009 is getting close…

If you want to meet me or one of our team, here are some of the sessions we’ll probably attend:

  • The preconference
  • Day 1
    TechDays day2
  • Day 2
    TechDays day3

Hope to meet you there

I added a project to CodePlex last week:

MailChimp Sync Module makes it easier for developers to synchronize their lists from any datasource to mailchimp.
It’s developed in C# on the mailchimp .NET wrapper.

Thank you, MailChimp, for the link on your blog.