Upload Files to Salesforce Documents

You can create a folder in Salesforce and provide the Folder Id to upload a file: 


//create a new document and name it
Document document = new Document();
document.Name = string.Concat(mediaItem.DisplayName, ".", mediaItem.Extension);
 
//get the document as a byte array
byte[] bytes = ReadFully(mediaItem.GetMediaStream());
document.Body = Convert.ToBase64String(bytes);
document.ContentType = mediaItem.MimeType;
document.FolderId = "00l60000001JaLm";
document.Description = key;

//save the document
DocumentService DS = new DocumentService(this.SalesforceSessionInstance);
SaveResult saveResult = DS.Insert(document);