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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to publish a document to sharepoint using a web form

Status
Not open for further replies.

f0z

Programmer
Jan 10, 2003
48
US
Not sure whether this should go here or in the sharepoint section.

Basically I want to create a web app that will allow the user to browse (using the input type="file") the local machine, select a document, click a button and the document selected gets published to our sharepoint server.

I've had a quick look around and found some code that is supposed to publish a document from a web app but I just cant seem to get it working.

Here's the code I'm running in the Page_Load:

Code:
PKMCDO.KnowledgeVersion docKnowVer = new PKMCDO.KnowledgeVersion();
PKMCDO._Stream docStream;

PKMCDO.KnowledgeDocument KnowDoc = new PKMCDO.KnowledgeDocument();

docStream = (PKMCDO._Stream)KnowDoc.OpenStream( (object) System.Type.Missing, PKMCDO.EnumKnowledge_StreamOpenSourceType.pkmOpenStreamUnspecified, null, PKMCDO.ConnectModeEnum.adModeUnknown,null,null);

docStream.SetEOS();
docStream.LoadFromFile(@"c:\testdoc2.txt");
docStream.Flush();
KnowDoc.Title = "My Title";
KnowDoc.Author = "mzamora";
KnowDoc.Description = "Your description";

KnowDoc.DataSource.SaveTo("[URL unfurl="true"]http://servername/workspace/documents/folder/",[/URL] null, PKMCDO.ConnectModeEnum.adModeReadWrite, PKMCDO.RecordCreateOptionsEnum.adCreateOverwrite, PKMCDO.RecordOpenOptionsEnum.adDelayFetchStream, @"domain\username", "password");
            
docKnowVer.Checkin(KnowDoc,0,"An XML Doc");
docKnowVer.Publish(KnowDoc,0);

If anyone could help that would be great.

Cheers

foz
 
cancel this!

I did somemore browsing and it turns out that you've to put URL to the file rather than the folder you want to save it to as the first argument in the DataSource.SaveTo method.

If anyone has had a look at this I appreciate it.

foz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top