MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

on button click how to open a file from sharepoint document library

  Asked By: Kanna    Date: Apr 07    Category: MOSS    Views: 2452

hi ,

from asp.net,on button click how can i open a file in the document library folder. is my below code correct??

SPSite sp = new SPSite(urlName);
SPWeb sw = sp.OpenWeb();
Byte[] streamBuffer = null;
sp.AllowUnsafeUpdates = true;
sw.AllowUnsafeUpdates = true;
SPFile DocumentTemplate = sw.GetFile(path);
Stream documentTemplateStream = DocumentTemplate.OpenBinaryStream();
streamBuffer = new Byte[documentTemplateStream.Length];
documentTemplateStream.Read(streamBuffer, 0, streamBuffer.Length);
return streamBuffer;

is this correct way of opening a file...if any other solutions please help me out.



1 Answer Found

Answer #1    Answered By: Sirisha Reddimasi     Answered On: May 10

Simple way is you can use javascript and you can pass the doc url to open the doc in object model.

For other operations like check in check out, you can write an method and you pass doc id and command to this method. Fetch the doc using id and use javascript to open it.


Related Topics:



Related Post