kennedyeoin
Programmer
Hi,
I am trying to write c# code to add a new document to a document library. My current code is
SPDocumentLibrary contracts = (SPDocumentLibrary)mySite.Lists["Contracts"];
SPList contracts = mySite.Lists["Contracts"];
SPListItem newContract = contracts.Items.Add();
newContract.Update();
this throws an error saying to add an item to a file library use spFileCollection.Add.
I have tried using spFileCollection but it seems to be for uploading a document, I want to create a new doucment
Any help on this would be greatly appreciated.
Thanks
I am trying to write c# code to add a new document to a document library. My current code is
SPDocumentLibrary contracts = (SPDocumentLibrary)mySite.Lists["Contracts"];
SPList contracts = mySite.Lists["Contracts"];
SPListItem newContract = contracts.Items.Add();
newContract.Update();
this throws an error saying to add an item to a file library use spFileCollection.Add.
I have tried using spFileCollection but it seems to be for uploading a document, I want to create a new doucment
Any help on this would be greatly appreciated.
Thanks