0

i want to retrieve the files from sharepoint document libraries url to filestream using aspx and c# coding.

Can any help me how to do it......?

2 Answers 2

1

Use this method to get a File object from a URL:

http://msdn.microsoft.com/en-us/library/ms476063.aspx

Use this method to read the data to a stream:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfile.openbinarystream.aspx

If you want to go through all files in a document library, you'll need to write a method that opens an SPList instance of your library, then gets a collection of listitems (SPListItemCollection) from that list, and access the SPListItem.File object of each item.

1
  • I used SPFile to downlaod the file. Its downloaded. When i tried to open, it is saying that "File is Corrupted"....? Can you have an idea Why it is happening..?
    – user2587
    Commented Mar 11, 2011 at 7:14
0

I ran into this old question, but maybe this will help someone:

Microsoft.SharePoint.SPFile spFile = Microsoft.SharePoint.SPContext.Current.Web.GetFile( "subcat/test.docx" );

This will get the local file automatically for you, doing most of the work.

1
  • While this post may answer the question, we prefer more details such as "why". Please edit your post with additional details. See answer for general guidelines.
    – SPDoctor
    Commented May 7, 2012 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.