Jim McCusker
Guest
|
Posted:
Sun Jan 16, 2005 5:51 am Post subject:
RE: how to read files from document library |
|
|
You simply need to get an SPFile object for the file you wish to read and use
the .LoadBinary() method to get a byte[] of the files contents.
You can get the file by creating an SPWeb object from a SPSite object:
SPWeb myWeb = new SPSite(urlSite).OpenWeb();
then get the file using the .GetFile() method:
SPFile myFile = myWeb.GetFile(filePath);
Now that you have the file, you can read the contents using the OpenBinary()
byte[] fileContents = myFile.OpenBinary();
Also, if you want the file contents in a string, you can use the SPWeb
method .GetFileAsString():
string fileContents = myWeb.GetFileAsString(filePath);
That's about it...
--Jim
"ashish" wrote:
| Quote: | hi
how do i read contents of files present in a document library. the library
is supposed to contain excel files.
thnx |
|
|