Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter is incorrect - error on SaveTo

Status
Not open for further replies.

spsdev

Programmer
Dec 3, 2004
4
US
I am new to SharePoint. I am trying to upload a document to SharePoint from my hard drive. I get "Parameter is incorrect" error on SaveTo method. Please help! Below is the code I am using -

using System;
using System.Reflection;

namespace ConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
PKMCDO.KnowledgeDocument oDoc = new PKMCDO.KnowledgeDocument();
PKMCDO.KnowledgeFolder oFolder = new PKMCDO.KnowledgeFolder();
ADODB._Stream oWrkStream;


//TODO: Change the following variables to reflect your SharePoint Portal Server environment.
String sHref=" Documents/TestDoc.txt";
String sFilePath = "c:\\TestDoc.txt" ;
String sAuthor = "AuthorName";
String sTitle = "TestDocument";
String sDesc = "Test Description";

Object vEmpty = Missing.Value;

oWrkStream = (ADODB._Stream )oDoc.OpenStream(
vEmpty,
PKMCDO.EnumKnowledge_StreamOpenSourceType.pkmOpenStreamUnspecified,
"",
PKMCDO.ConnectModeEnum.adModeReadWrite,
"",
"");

oWrkStream.Type = ADODB.StreamTypeEnum.adTypeBinary;
oWrkStream.SetEOS();
oWrkStream.LoadFromFile(sFilePath);
oWrkStream.Flush();


oDoc.Author = sAuthor;
oDoc.Title = sTitle;
oDoc.Description = sDesc ;

oDoc.DataSource.SaveTo (
sHref,
null,
PKMCDO.ConnectModeEnum.adModeWrite,
PKMCDO.RecordCreateOptionsEnum.adCreateNonCollection,
PKMCDO.RecordOpenOptionsEnum.adOpenSource,
"" ,
"");

oDoc = null;
oWrkStream= null;
//
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top