First, use the WSS interface to add the document DOC
// Sqlconnection Cn = new sqlconnection (configurationsettings. appsettings ["sps_site"]. tostring ());
// CN. open ();
// Sqlcommand cmd = cn. createcommand ();
// Doc = folder. adddocument (filename, new byte [0], false );
// Try
//{
// Doc. ID = convert. toint32 (Doc. spfile. item ["ID"]);
//// Change the size
// Cmd. commandtext = "Update docs set size =" + filesize. tostring () + "where doclibrowid =" + Doc. ID + "and listid = '" + doclibguid + "'";
// Cmd. executenonquery ();
//
// Cmd. commandtext = "declare @ content varbinary (16 )"
// + "Select @ content = textptr (content) from docs where doclibrowid =" + Doc. ID + "and listid = '" + doclibguid + "'"
// + "Updatetext docs. Content @ content @ length 0 @ block ";
// Cmd. Parameters. Add ("@ block", system. Data. sqldbtype. Image );
// Cmd. Parameters. Add ("@ length", system. Data. sqldbtype. INT );
// Int Len = 8040000;
// Byte [] doublebuffer = new byte [Len];
// Int Iread = 0;
// While (Iread <filesize)
//{
// Singlefile. inputstream. Read (doublebuffer, 0, Len );
// Cmd. Parameters ["@ block"]. value = doublebuffer;
// Cmd. Parameters ["@ length"]. value = Iread;
// Cmd. executenonquery ();
// Iread + = Len;
//}
//}
// Catch (exception ex)
//{
// Folder. deletedocument (filename );
// Throw ex;
//}
// Finally
//{
// CN. Close ();
// CN. Dispose ();
//}