SharePoint - READING ITEMS OF A PARTICULAR FOLDER....

Asked By veni
25-Jul-11 05:20 AM

HI,
I AM HAVING FOUR FOLDERS IN A DOCUMENT LIBRARY,
NOW I AM TRYING TO VIEW THE ITEMS  OF A PARTICULAR  FOLDER OF THIS DOCUMENT LIBRARY IN ANOTHER SITE..
  Reena Jain replied to veni
25-Jul-11 05:30 AM
Hi,

try this code to read the items of particular folder

// Create a SPQuery Object
SPQuery curQry = new SPQuery();
curQry.Folder = folder;
 
//Write the query
curQry.Query = "<Where><Eq><FieldRef Name='FIELD-NAME' /><Value Type='Text'>OBJ-VALUE</Value></Eq></Where>";
SPListItemCollection items = list.GetItems(curQry);

Hope this will help you
  Ravi S replied to veni
25-Jul-11 05:31 AM
HI

// Create a SPQuery Object

 

SPQuery curQry = new SPQuery();

curQry.Folder = folder;

 

//Write the query 

curQry.Query = "<Where><Eq><FieldRef Name='FIELD-NAME' /><Value Type='Text'>OBJ-VALUE</Value></Eq></Where>";

SPListItemCollection items = list.GetItems(curQry);

  Ravi S replied to veni
25-Jul-11 05:33 AM
HI

To get file names from the specified directory, use static method Directory.Get­Files.

Lets have these files and subfolders in „c:\MyDir“ folder:

Get files from directory

Method Directory.GetFiles returns string array with files names (full paths).

[C#]
using System.IO;

string[] filePaths = Directory.GetFiles(@"c:\MyDir\");
// returns:
// "c:\MyDir\my-car.BMP"
// "c:\MyDir\my-house.jpg"

Get files from directory (with specified extension)

You can specify search pattern. You can use wildcard specifiers in the search pattern, e.g. „*.bmp“ to select files with the extension or „a*“ to select files beginning with letter „a“.

[C#]
string[] filePaths = Directory.GetFiles(@"c:\MyDir\", "*.bmp");
// returns:
// "c:\MyDir\my-car.BMP"

Get files from directory (including all subdirectories)

If you want to search also in subfolders use parameter SearchOption.A­llDirectories.

[C#]
string[] filePaths = Directory.GetFiles(@"c:\MyDir\", "*.bmp",
                                         SearchOption.AllDirectories);
// returns:
// "c:\MyDir\my-car.BMP"
// "c:\MyDir\Friends\james.BMP"


  James H replied to veni
  Riley K replied to veni
25-Jul-11 07:10 AM
The best way is to make an initial query to get all top level folders in the document library by including in your where clause the test for FSObjType = 1. This will return folders only. Next you can iterate the datatabel returned.

 
  
public static DataTable GetListItemJustFolders()
  {
    string query = "<mylistitemrequest><Query><Where><Eq><FieldRef Name=\"FSObjType\" /><Value Type=\"Lookup\">1</Value></Eq></Where></Query><ViewFields><FieldRef Name=\"EncodedAbsUrl\"/><FieldRef Name=\"ID\" /><FieldRef Name=\"FileRef\" /><FieldRef Name=\"ID\" /><FieldRef Name=\"Title\" /></ViewFields><QueryOptions></QueryOptions></mylistitemrequest>";
    DataTable dt = null;
 
    using(listservice.Lists listProxy = new listservice.Lists())
    {
 
    listProxy.UseDefaultCredentials = true;
 
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(query);
 
    XmlNode queryNode = doc.SelectSingleNode("//Query");
    XmlNode viewNode = doc.SelectSingleNode("//ViewFields");
    XmlNode optionNode = doc.SelectSingleNode("//QueryOptions");
 
    XmlNode retNode = listProxy.GetListItems("Shared Documents", string.Empty, queryNode, viewNode, string.Empty, optionNode, "e5bc34ff-6cde-4fee-aa4c-356baa57b37b");
 
    DataSet ds = new DataSet();
    using (StringReader sr = new StringReader(retNode.OuterXml))
      ds.ReadXml(sr);
 
    if (ds.Tables["Row"] != null && ds.Tables["Row"].Rows.Count > 0)
    {
      var folderUrls = from f in ds.Tables["Row"].AsEnumerable() select f["ows_EncodedAbsUrl"];
      dt = ds.Tables["Row"].Copy();
 
      foreach (string folderUrl in folderUrls)
      {
      GetListItemSubFolders(folderUrl, dt);
      }
 
    }
 
    }
 
    return dt;
 
  }
 
  public static void GetListItemSubFolders(string parentFolder, DataTable retTable)
  {
 
    string query = "<mylistitemrequest><Query><Where><Eq><FieldRef Name=\"FSObjType\" /><Value Type=\"Lookup\">1</Value></Eq></Where></Query><ViewFields><FieldRef Name=\"EncodedAbsUrl\"/><FieldRef Name=\"ID\" /><FieldRef Name=\"Title\" /></ViewFields><QueryOptions><Folder>" + parentFolder + "</Folder></QueryOptions></mylistitemrequest>";
    DataTable dt = null;
 
    using (listservice.Lists listProxy = new listservice.Lists())
    {
    listProxy.UseDefaultCredentials = true;
 
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(query);
 
    XmlNode queryNode = doc.SelectSingleNode("//Query");
    XmlNode viewNode = doc.SelectSingleNode("//ViewFields");
    XmlNode optionNode = doc.SelectSingleNode("//QueryOptions");
 
    XmlNode retNode = listProxy.GetListItems("Shared Documents", string.Empty, queryNode, viewNode, string.Empty, optionNode, "e5bc34ff-6cde-4fee-aa4c-356baa57b37b");
 
    DataSet ds = new DataSet();
    using(StringReader sr = new StringReader(retNode.OuterXml))
      ds.ReadXml(sr);
 
 
    if (ds.Tables["Row"] != null && ds.Tables["Row"].Rows.Count > 0)
    {
      var folderUrls = from f in ds.Tables["Row"].AsEnumerable() select f["ows_EncodedAbsUrl"];
      dt = ds.Tables["Row"].Copy();
 
      foreach (string folderUrl in folderUrls)
      {
      GetListItemSubFolders(folderUrl, dt);
      }
 
      retTable.Merge(dt);
 
    }
     
    }
 
    
  }
}
 
}
  Vickey F replied to veni
25-Jul-11 07:54 AM
you can use the SPDataSource to display items from a specific folder in a SharePoint document library.

like this-

<SharePoint:SPDataSource ID="dsFolder"
    runat="server"
    IncludeHidden="true"
    DataSourceMode="List"
    UseInternalName="true"
    SelectCommand="&lt;View&gt;&lt;/View&gt;">
    <SelectParameters>
        <asp:Parameter Name="ListName" DefaultValue="Project Documents" />
        <asp:Parameter Name="RootFolder" DefaultValue="ProjectDocuments/Folder1" />
    </SelectParameters>
</SharePoint:spdatasource>


follow this link-

http://www.sharepointconfig.com/2010/11/displaying-files-from-a-specific-folder-using-spdatasource/

Hope this will help you.
Create New Account
help
the right permissions on the content type. Then, I created a column "external data" in Sharepoint that I linked to my content type. When I want to change the data in EventID Level Message Correlation 11 / 13 / 2011 00:08:30.31 w3wp.exe (0x1D9C) 0x1038 SharePoint Foundation Monitoring nasq Medium Entering monitored scope (Request (GET:http: / / tricoflex:80 / CRM / _layouts / FldNewEx Cust%2E%20Relation%20ID&DescriptionParam = &VldFormulaParam = &VldMessageParam = )) 11 / 13 / 2011 00:08:30.31 w3wp.exe (0x1D9C) 0x1038 SharePoint Foundation Logging Correlation Data xmnv Medium Name = Request (GET:http: / / tricoflex:80 / CRM / _layouts / FldNewEx e307-4c5d-b470-c4351e5dff53 11 / 13 / 2011 00:08:30.32 w3wp.exe (0x1D9C) 0x1038 SharePoint Foundation Logging Correlation Data xmnv Medium Site = / 9694064f-e307-4c5d-b470-c4351e5dff53 11 / 13 / 2011 00:08:30.35 w3wp.exe (0x1D9C) 0x1038 SharePoint Foundation Monitoring b4ly Medium Leaving Monitored Scope (Request (GET:http: / / tricoflex:80 / CRM / _layouts / FldNewEx e307-4c5d-b470-c4351e5dff53 11 / 13 / 2011 00:08:30.45 wsstracing.exe (0x06A0) 0x17A0 SharePoint Foundation Unified Logging Service b9wt High Log retention limit reached. Log file 'C: \ Program Files log' has been deleted. 11 / 13 / 2011 00:08:30.45 wsstracing.exe (0x06A0) 0x17A0 SharePoint Foundation Tracing Controller Service 8096 Information Usage log retention limit reached. Some old usage log files have been deleted. 11 / 13 / 2011 00:08:30.57 w3wp.exe (0x1D9C) 0x1038 SharePoint Foundation Monitoring nasq Medium Entering monitored scope (Request (GET:http: / / tricoflex:80 / SiteAssets / SitePages / Accueil
project con sharepoint SharePoint SharePoint Portal Server Dev Discussions Sharepoint (1) Laurent (1) Cotton (1) Conectarme (1) Intentar (1) Liliana (1) Error (1) Project (1 Laurent Cotton www.bewise.fr es un error que sale al intentar conectarme con el sharepoint keywords: project, con, sharepoint description: !- - Web.Config configuration File- - configuration system.web customErrors mode = On deafaultRedirect = mycustompage.htm system
access into sharepoint SharePoint Sharepoint is new to my organisation and we are on the verge of deploying it to and import those? How have others resolved this issue? Your help is most appreciated, Matt SharePoint Discussions SharePoint (1) InfoPath (1) WSS 3.0 and MOSS 2007 (you didn't say which SharePoint product *and version* you were asking about) allow you with Access 2007 to synchronize (in both directions) Access tables and SharePoint Lists. It probably works in both directions (with some restrictions on field types used) although and then open that file using the template you created in InfoPath. keywords: access, into, sharepoint description: Sharepoint is new to my organisation and we are on the verge of deploying
wiki sharepoint SharePoint Hi Does someone know if there are any good wiki webparts available for sharepoint SharePoint Discussions Sharepoint (1) Webparts (1) SharePoint v3 (MOSS 2007 and WSSv3) includes Wiki functionality. Engelbert Have you heard about the Wiki to this work. Ben Aloha derksj, For 2003 I don't know of any, but SharePoint 2007 has a Wiki template included out of the box. -Ben- Ben M. Schorr - MVP http: / / www.rolandschorr.com Microsoft OneNote FAQ: http: / / www.factplace.com / onenotefaq.htm keywords: wiki, sharepoint description: Hi Does someone know if there are any good wiki webparts available for sharepoint