MOSS Forum

 
Home » Forum » MOSS       Ask a questionRSS Feeds

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

  Asked By: Kanna Abc         Date: Apr 07, 2011      Category: MOSS      Views: 678
 

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);
documentTemplateStream.Dispose();
return streamBuffer;

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

Tagged:                      

 

1 Answer Found

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

Hi,
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.

 


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].