I am trying to import a bunch of files into SharePoint from an old collaboration system we are getting rid of. The problem I am facing is the file information must be retained. For example, if the file was created 12/14/2007 by Joe, and then modified 4/10/2009 by Sue, I need to make sure that information is set in SharePoint when I add the file.
It looks like the needed properties in SPFile are "get" only.
I also tried to use a hashtable to try and force those values upon the file upload as shown in the code below, but that didn't work either.
private static void UploadFile(string srcUrl, string destUrl)
using (SPWeb site = new SPSite(destUrl).OpenWeb())
//## Put the file into a filestream
FileStream fStream = File.OpenRead(srcUrl);
byte contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
//## A hashtable for the file metadata
Hashtable metadata = new Hashtable();
metadata.Add("ModifiedBy", "Joe Blow");
View Complete Post