<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>SharePoint</title>
        <link>http://geekswithblogs.net/AnneBougie/category/9511.aspx</link>
        <description>SharePoint</description>
        <language>en-US</language>
        <copyright>Anne Bougie</copyright>
        <managingEditor>anne.bougie@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Another SharePoint Content Deployment Issue</title>
            <link>http://geekswithblogs.net/AnneBougie/archive/2009/03/06/sharepoint-content-deployment.aspx</link>
            <description>&lt;p&gt;The fantastic 40 templates from Microsoft can cause issues with content deployment. The following error prevents content deployment with the templates installed:&lt;/p&gt;
&lt;p&gt;1. The content type name cannot contain: \ / : * ? " # % &amp;lt; &amp;gt; { } | ~ &amp;amp;, two consecutive periods (..), or special characters such as a tab. at Microsoft.SharePoint.SPContentType.ValidateName(String name) at Microsoft.SharePoint.SPContentType.ValidateNameWithResource(String strVal, String&amp;amp; strLocalized) at Microsoft.SharePoint.SPContentType.set_Name(String value) at Microsoft.SharePoint.Deployment.ContentTypeSerializer.UpdateContentTypeMetaData(SPContentType sourceContentType, SPContentType targetContentType, String contentTypeXml) at Microsoft.SharePoint.Deployment.ContentTypeSerializer.UpdateContentType(SPContentType sourceContentType, SPContentType targetContentType, String contentTypeXml, ImportObjectManager importObjectManager) at Microsoft.SharePoint.Deployment.ContentTypeSerializer.ProcessContentType(SPContentType sourceContentType, String contentTypeXml, ImportObjectManager importObjectManager, Boolean IsParentSystemObject) at Microsoft.SharePoint.Deployment.ContentTypeSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType, Boolean isChildObject) at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope) at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream) at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream) at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader) at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects() at Microsoft.SharePoint.Deployment.SPImport.Run()&lt;/p&gt;
&lt;p&gt;To fix this error, the Fields.xml file located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\TSATypes\Fields.xml needs to be modified. This xml file contains many entries where the field id is set to a Guid. The problem is that this Guid contains curly braces in it: &amp;lt;Field ID="{38F29346-B895-4ece-9BD6-90C7D1E6DA95}". These braces need to be removed. &lt;/p&gt;
&lt;p&gt;Make a copy of this file before making modifications in case you have problems after making this change. Then simply do a find and replace on "{ and }" and remove the braces. &lt;/p&gt;
&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a4f3c58c-ac72-4279-91a9-0c913d226319" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/SharePoint"&gt;SharePoint&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129883"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129883" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AnneBougie/aggbug/129883.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AnneBougie</dc:creator>
            <guid>http://geekswithblogs.net/AnneBougie/archive/2009/03/06/sharepoint-content-deployment.aspx</guid>
            <pubDate>Fri, 06 Mar 2009 17:38:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AnneBougie/comments/129883.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AnneBougie/archive/2009/03/06/sharepoint-content-deployment.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/AnneBougie/comments/commentRss/129883.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SharePoint Content Deployment Issue</title>
            <link>http://geekswithblogs.net/AnneBougie/archive/2009/03/06/sharepoint-content-deployment-issue.aspx</link>
            <description>&lt;p&gt;The following error can occur during content deployment:&lt;/p&gt;
&lt;p&gt; The changeToken refers to a time before the start of the current change log.    &lt;br /&gt;
&lt;br /&gt;
The changeToken refers to a time before the start of the current change log. at Microsoft.SharePoint.Deployment.SPExport.ThrowInvalidChangeTokenError(DateTime minChangeTime, Int32 minChangeNumber) at Microsoft.SharePoint.Deployment.SPExport.GetIncrementalChanges() at Microsoft.SharePoint.Deployment.SPExport.CalculateObjectsToExport() at Microsoft.SharePoint.Deployment.SPExport.Run()&lt;/p&gt;
&lt;p&gt;   Content deployment job 'Entire site' failed.The exception thrown was 'Microsoft.SharePoint.SPException' : 'The changeToken refers to a time before the start of the current change log.'&lt;/p&gt;
&lt;p&gt;This error happens when more than 15 days have passed since the last deployment, and you have the job set to use incremental deployment. The fix is really easy. You just have to change the deployment options on the deployment job to deploy all content instead of deploying only new or changed content. Run the content deployment once, then you can change back to incremental deployment. &lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:d84c7927-f12d-4c80-87b5-3f1f7a0f8210" style="margin: 0px; padding: 0px; display: inline; float: none;"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/SharePoint" rel="tag"&gt;SharePoint&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129880"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129880" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AnneBougie/aggbug/129880.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AnneBougie</dc:creator>
            <guid>http://geekswithblogs.net/AnneBougie/archive/2009/03/06/sharepoint-content-deployment-issue.aspx</guid>
            <pubDate>Fri, 06 Mar 2009 15:01:18 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AnneBougie/comments/129880.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AnneBougie/archive/2009/03/06/sharepoint-content-deployment-issue.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/AnneBougie/comments/commentRss/129880.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SharePoint Adventures - Reading an Excel Spreadsheet From A Stream</title>
            <link>http://geekswithblogs.net/AnneBougie/archive/2009/01/29/sharepoint-reading-an-excel-from-a-stream.aspx</link>
            <description>When I needed to read an Excel spreadsheet from a SharePoint site, it seemed like a simple enough request. Previously, whenever I needed to open an Excel file, I used an OleDb connection with the following connection string:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;       Data Source={0};Persist Security Info=False;&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;       Extended Properties=""Excel 12.0;HDR=YES""";&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;connectionString = string.Format(connectionString, filePath);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Of course, you can't open the file from the SharePoint site this way. So, my first hurdle was to figure out how to download the file from the web site. The System.Net namespace provides a very easy way to do this:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;WebClient client = new WebClient();&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;client.UseDefaultCredentials = true;&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;Stream stream = client.OpenRead(url);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now I had my file as a stream, so I thought I'd just extract it, save it to a temporary file, then read it in in the usual way. Problem solved. This next bit of code should probably be optimized a little so I'm not resizing the array every single loop:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;BinaryReader brdr = new BinaryReader(stream);&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;byte[] result = new byte[0];&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;int bufferSize = 32768; // 32k&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;byte[] buffer = new byte[bufferSize];&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;long pos = 0;&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;while (true)&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;{&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      buffer = brdr.ReadBytes(bufferSize);&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      if (pos &amp;gt; 0)&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      {&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            // copy old data to bigger result&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            byte[] temp = new byte[result.LongLength];&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            Array.Copy(result, temp, result.LongLength);&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            result = new byte[temp.LongLength + buffer.Length];&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            Array.Copy(temp, result, temp.LongLength);&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            // add new data&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            for (int i = 0; i &amp;lt; buffer.Length; i++)&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            {&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;                result[pos + i] = buffer[i];&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            }&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            pos += buffer.Length;&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      }&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      else&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      {&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            result = new byte[buffer.Length];&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            Array.Copy(buffer, result, buffer.Length);&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            pos = buffer.Length;&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      }&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      if (buffer.Length &amp;lt; bufferSize)&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;            break;&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;}&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;string tempFile = Path.Combine(Environment.GetEnvironmentVariable("TMP"), &lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      "CopyList.xlsx");&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;using (var fs = new FileStream(tempFile, FileMode.OpenOrCreate))&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;{&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      var writer = new BinaryWriter(fs);&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      writer.Write(result, 0, result.Length);&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      writer.Close();&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;      fs.Close();&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This worked beautifully on my development machine, but this is part of a larger program that is manipulating a SharePoint site via the SharePoint API. Therefore, it has to run on the server, which is 64-bit. When I first ran it, I received the error "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine" . So, I did a little digging around, and found out that maybe I needed to install the driver. It is available from Microsoft as a &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=7554F536-8C28-4598-9B72-EF94E038C891&amp;amp;displaylang=en"&gt;separate download&lt;/a&gt;, so I thought I was good to go. I installed it, and was still receiving the same error. Huh??!! Then I did a little *more* digging, and found out that there is no OleDb driver for opening Excel files on a 64-bit machine. Fine. No problem. Just compile the project as x86, and I'm good to go. Right? Well, wrong, actually. When the project is compiled in 32-bit, I can't access the SharePoint sites. Aaaaarrrrrrrhhhh! What to do? Then, I'm looking all over, trying to find a way to read an Excel file directly from a stream. How hard can it be, right?&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;&amp;lt;SARCASM&amp;gt;&lt;/span&gt;&lt;br /&gt;
Actually, Microsoft has this really &lt;a href="http://download.microsoft.com/download/0/B/E/0BE8BDD7-E5E8-422A-ABFD-4342ED7AD886/Excel97-2007BinaryFileFormat(xls)Specification.pdf"&gt;handy little guide&lt;/a&gt; that tells you just how to do it. It's only 349 pages. Turns out Excel's native format is something called a BIFF (Binary Interchange File Format). So, you just have to parse all the bytes from the stream into the right format. What a treat!&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;&amp;lt;/SARCASM&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I know who I'd like to BIFF about now. Anyway, I did *even more* digging around, and I found some code from someone who has done just that. &lt;a href="http://www.codeplex.com/ExcelDataReader"&gt;Excel Data Reader&lt;/a&gt;  Thanks, iciobanu! However, it only works for Excel 2003 format. Now that is finally a problem I can easily solve! Save the spreadsheet to 2003 format, and read it in. Are we there yet? Almost! I was getting errors because the stream object returned from the web download didn't support seeking, which this code relies on. So, save the stream out to a temp file (back to that again), and read it back in as a FileStream object, which supports seeking, and my problems are, at long last, solved.&lt;br /&gt;
&lt;br /&gt;
And that is how you open an Excel file from a SharePoint site into a spreadsheet without using a generic OleDb connection. Sucess at long last! Isn't there some famous quote somewhere about persistence paying off? 
&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a4f3c58c-ac72-4279-91a9-0c913d226319" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/SharePoint"&gt;SharePoint&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129080"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129080" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AnneBougie/aggbug/129080.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AnneBougie</dc:creator>
            <guid>http://geekswithblogs.net/AnneBougie/archive/2009/01/29/sharepoint-reading-an-excel-from-a-stream.aspx</guid>
            <pubDate>Thu, 29 Jan 2009 22:40:12 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AnneBougie/comments/129080.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AnneBougie/archive/2009/01/29/sharepoint-reading-an-excel-from-a-stream.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/AnneBougie/comments/commentRss/129080.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Part 1: Copy a SharePoint List Programmatically</title>
            <link>http://geekswithblogs.net/AnneBougie/archive/2009/01/23/copy-a-sharepoint-list.aspx</link>
            <description>I've been working with the SharePoint API lately. One of my tasks is to copy SharePoint lists from one site to another site. This can be done in code as long as the two sites are on the same machine. It's OK if they are in different web applications, but it can't be from one server to another. If you need to copy from one server to another, you either need to do an export/import, or find a way to save the settings and import them on the new machine. I believe you can use the SharePoint Web Services to accomplish this, though. I haven't worked with that yet. &lt;br /&gt;
&lt;br /&gt;
Anyway, it took a lot of digging around to figure out all the things I needed to copy lists, so I thought I'd post the code that is working for me. This post is only going to cover copying a basic list. I am planning on several more posts to handle document libraries, wikis, and other special cases. Each has their own challenges. &lt;br /&gt;
&lt;br /&gt;
The requirements for me are to copy the bulk of the lists of a large SharePoint site to a new site with a different structure. Therefore, content and deploy is not going to work. Also, they are redesiging the pages, so they really only wanted the lists. What I'm doing is creating a new list on the new site and copying all the properties, so any metadata, such as who last modified the list, is unfortunately lost. &lt;br /&gt;
&lt;br /&gt;
Here's the code:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New;"&gt;&lt;span style="color: rgb(51, 153, 102);"&gt;// Instantiate web instances&lt;/span&gt;&lt;br /&gt;
SPSite sourceSite = new SPSite(@"http://SharePointServer:31001");&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;SPWeb sourceWeb = sourceSite.RootWeb;&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;SPSite destSite = new SPSite(@"http://SharePointServer:31002");&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;SPWeb destWeb = destSite.RootWeb;&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New;"&gt;&lt;span style="color: rgb(51, 153, 102);"&gt;// Get a reference to the source list&lt;/span&gt;&lt;br /&gt;
SPList sourceList = sourceWeb.GetList("/Lists/Announcements");&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
 &lt;span style="font-family: Courier New;"&gt;&lt;br /&gt;
&lt;span style="color: rgb(51, 153, 102);"&gt;// if the list exists on the destination site, delete it&lt;/span&gt;&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;try&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;   SPList temp = destWeb.Lists[sourceList.Title];&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;   destWeb.Lists.Delete(temp.ID);&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New;"&gt;&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;catch { }&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New;"&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;// create new list on the destination web with same properties&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;Guid newListID = destWeb.Lists.Add(sourceList.Title, sourceList.Description,&lt;br /&gt;
                                   sourceList.BaseTemplate);&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;SPList destList = destWeb.Lists[newListID];&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New; color: rgb(51, 153, 102);"&gt;// copy items&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;foreach (SPListItem item in announcements.Items)&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;   SPListItem newDestItem = destList.Items.Add();&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;   foreach (SPField field in sourceList.Fields)&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;   {&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;      if (!field.ReadOnlyField)&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;      newDestItem[field.Id] = item[field.Id];&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;   }&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;   newDestItem.Update();&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Courier New; color: rgb(51, 153, 102);"&gt;// set quicklaunch settings&lt;/span&gt;&lt;br style="font-family: Courier New;" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;destList.OnQuickLaunch = sourceList.OnQuickLaunch;&lt;/span&gt;&lt;br style="font-family: Courier New; color: rgb(0, 0, 0);" /&gt;
&lt;span style="font-family: Courier New; color: rgb(0, 0, 0);"&gt;destList.Update();&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;

&lt;div style="margin: 0px; padding: 0px; display: inline; float: none;" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a4f3c58c-ac72-4279-91a9-0c913d226319" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/SharePoint"&gt;SharePoint&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128937"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128937" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AnneBougie/aggbug/128937.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AnneBougie</dc:creator>
            <guid>http://geekswithblogs.net/AnneBougie/archive/2009/01/23/copy-a-sharepoint-list.aspx</guid>
            <pubDate>Fri, 23 Jan 2009 18:18:43 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AnneBougie/comments/128937.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AnneBougie/archive/2009/01/23/copy-a-sharepoint-list.aspx#feedback</comments>
            <slash:comments>8</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/AnneBougie/comments/commentRss/128937.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>