Archive for March, 2010

SP - Uploading files to SharePoint document library

here we go, just some simple upload code that uploads documents into a document library.
It also checks if the same file exist in the destination library before upload.

SPSite site = new SPSite(”http://mysharepointsite”);
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true; // i always add this in to prevent security errors
Stream fStream = postedFile.InputStream;
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, [...]

Comments (5)

CRM 4 - Update Rollup 9

Well, update roll up 9 is out (how the hell did we get to 9??)! Jeez with all these update packs there needs to be a full job to implement all these updates on servers and implement the necessary changes the update pack doesn’t.
KB article: http://support.microsoft.com/default.aspx?kbid=977650
Download: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=5869f2b3-d1a0-4f71-8be3-fde6e8053a2e

Leave a Comment

Mini Preview Window for Contact Lookup Field

Looks cool doesn’t it. well here goes nothing..
to achieve the above you will need the following (click read more link..)

// the following code is for the hover over lookup window
function OnCrmPageLoad()
{
/*
Reference the to Lookup, Provide the lookup (control) id.
*/
var PrvToLui = new LookupPreview(”new_primarycontactid”);
/*
Add Account Preview Information [...]

Comments (187)

Update Filename or List Item name programmatically in SharePoint/WSS

As simple as it sounds, it ain’t simple.
you would of thought the following would work:

SPFile file = web.GetFile(strUrl);
file.name = “mynameFilename.txt”;
file.Update();

does not compute..
There are 2 ways I’ve found of accomplishing this:
1. using the SPFile.MoveTo method:

string strUrl = “http://mysharepointsite/myolddocumentlibrary/Filename.txt”;
string newFileUrl = “http://mysharepointsite/mynewdocumentlibrary/mynewFilename.txt”;

SPSite site = new SPSite(”http://mysharepointsite”);
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true; // this will stop it [...]

Comments (1)