How to filter the Files from SharePoint Document Library based upon cloumn value

Hi
I should filter the files from document library. I have column called "Print Status" for the document library the value would be either "Yes" or "No".
Now i should filter out the files which has "Print Status" as a "Yes".
I am using SPFolder and SPFile from SharePoint Object Model to traverse the file in doc library.
How could i do it?
My Sample code:
foreach (SPFolder childFolder in folder.SubFolders)
  if (childFolder.Name != "Forms")
    AspControls.TreeNode trn = new System.Web.UI.WebControls.TreeNode(childFolder.Name, "", "~/_layouts/images/itdl.gif", childFolder.ServerRelativeUrl.ToString(), "");
    newNode = TraverseFiles(childFolder, trn);
                            // add the new node to the tree
                            rootNode.ChildNodes.Add(newNode);
                    // loop through the files
                    foreach (SPFile childFile in folder.Files)
                        // create a new node and add to the tree
                        AspControls.TreeNode childNode = new System.Web.UI.WebControls.TreeNode(childFile.Name + " (" + childFile.TimeLastModified.ToShortDateString()
+ ")", Convert.ToString(childFile.Item["ID"]), "~/_layouts/images/" + childFile.IconUrl, childFile.ServerRelativeUrl.ToString(), "");
                        rootNode.ChildNodes.Add(childNode);
Thanks
Poomani Sankaran.

Why do you transvers the file an not use a camp query? In a CAML query you can filter the print status and are able to get all files and folder objects at once.
Check out the following post: http://social.msdn.microsoft.com/Forums/sharepoint/en-US/8c45b5e2-1fb8-435c-a97d-1d8c6d288d4c/caml-query-to-query-all-the-files-and-folders-in-document-library?forum=sharepointdevelopmentprevious
Kind regards
Stefan
http://www.n8d.at/blog
Follow me on Twitter: StFBauer |
n8design
Microsoft Community Contributor 2011 / 2012
MCTS - SharePoint / WSS Configuration and Development

Similar Messages

  • Download older version of a file from SharePoint Document Library using CSOM and 404 error

    Hi,
    I am trying to download previous versions including Major and Minor versions of documents from SharePoint Online using CSOM. I get 404 error when I try to download the file. I found several posts on various discussion forums where people are getting same
    error but none of those have any solution/answer. Below is one of the threads and sample code I have tried that results in 404 error. If I use the link in browser directly, I am able to download the file. Also I am able to download the current version of file
    using CSOM without any problem, it is only the older versions that give me 404 in CSOM.
    http://qandasys.info/how-to-download-the-historical-file-version-content-using-csom/
    public int GetStreamFromFile(string docid, string lib, string fileurl, ClientContext clientContext, int iuserid, string Version, bool isCurrrent)
    if(!isCurrent)
    List LibraryName = clientContext.Web.Lists.GetByTitle(lib);
    clientContext.Load(LibraryName);
    clientContext.ExecuteQuery();
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml = "" + fileurl +
    Microsoft.SharePoint.Client.ListItemCollection collListItem = LibraryName.GetItems(camlQuery);
    clientContext.Load(collListItem, items => items.Include(item => item.Id, item => item["FileLeafRef"], item => item["LinkFilename"],
    item => item["FileRef"], item => item["File_x0020_Size"], item => item["DocIcon"], item => item.File.Versions));
    //clientContext.Load(collListItem);
    clientContext.ExecuteQuery();
    foreach (Microsoft.SharePoint.Client.ListItem oListItem in collListItem)
    //string fileurl1 = (string)oListItem["FileRef"];
    //string filename = (string)oListItem["LinkFilename"];
    foreach (FileVersion version in oListItem.File.Versions)
    if (Version == version.VersionLabel)
    //Added excutequery to get object one more time as per blog
    //http://social.technet.microsoft.com/Forums/de-DE/sharepointdevelopmentprevious/thread/88a05256-8694-4e40-863d-6c77512e079b
    clientContext.ExecuteQuery();
    FileInformation fileInformation = ClientOM.File.OpenBinaryDirect(clientContext,version.Url);
    bytesarr = ReadFully(fileInformation.Stream);
    Darwaish

    Hi,
    According to your description,
    I know you want to get older version of a file from SharePoint Document Library using Client Object Model.
    The following code snippet for your reference:
    public void GetVersions()
    ClientContext clientContext = new ClientContext(“http://SPSite”);
    Web site = clientContext.Web;
    clientContext.Load(site);
    clientContext.ExecuteQuery();
    File file = site.GetFileByServerRelativeUrl(“/Shared Documents/mydocument.doc”);
    clientContext.Load(file);
    clientContext.ExecuteQuery();
    ListItem currentItem = file.ListItemAllFields;
    clientContext.Load(currentItem);
    clientContext.ExecuteQuery();
    FileVersionCollection versions = file.Versions;
    clientContext.Load(versions);
    clientContext.ExecuteQuery();
    if (versions != null)
    foreach(FileVersion _version in versions)
    Console.WriteLine(“Version : {0}”,_version.VersionLabel);
    More information:
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.file.versions.aspx
    Best Regards,
    Dennis Guo

  • Sharepoint 2010 - Archiving the files from one document library to another document library in sharepoint site

    I have a requirement to move the documents from one document library to another document library.
    Source Library - DocumentLib
    Destination Library - Archive
    Archive document library will have folders by fiscal year.
    Source documentlibrary has files from year 2012 till date.
    Archive folder will have folders by fiscal year -(fiscal year starts from July1st -June 30th )
    If the document is created date  between 1st  July 2012 -June 2013 then move the document to Archive document library and in  folder Fiscal Year 2013.
    If the document is created date  between 1st  July 2013 -June 2014 then move the document to Archive document library and in  folder Fiscal Year 2014.
    The structure of destination document library folder should be same as source document library.
    Please find attached the screenshot of the requirement.
    Files Type - Excel,pdf,microsoft outlook item
    Could we use Sharepoint designer workflow to achive this task?
    Any help on this will be appreaciated.

    Hi Asritha,
    According to your description, you want to create a workflow to meet the need.
    Per my knowledge, there is no built-in action which can move the documents from the current library to a folder in another library.
    I recommend to use the custom activity 'Copy List Item Extended' which need to be downloaded from
    http://spdactivities.codeplex.com/.
    Please per the steps below to deploy the custom activity to SharePoint:
    Download the activity form http://spdactivities.codeplex.com/
    Open Dos command prompt.
    Browse to the directory that you can access stsadm.exe. The default location in version 3.0 is C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\bin
    Type the stsadm commands: stsadm -o addsolution -filename C:\UsefulSPDWorkflowActivities_0.5.0\DP.Sharepoint.Workflow.wsp (“C:\UsefulSPDWorkflowActivities_0.5.0\” is the file path)
    Type the stsadm commands: stsadm -o deploysolution -name DP.Sharepoint.Workflow.wsp -allowgacdeployment -force -immediate 
    Open the Center Administration, Click System Setting->Manage Farm Solution-> dp.sharepoint.workflow.wsp->Deploy to the Web Application.
    After that, we can create a workflow to meet the need.
    Here is the detailed steps to create the workflow:
    Create a workflow associated with the Source Library DocumentLib and set the workflow to start when an item is created.
    Select If current item field equals value, change the settings to be If Current Item: Created is greater than 7/1/2012.
    Select If current item field equals value, change the settings to be If Current Item: Created is less than 6/30/2013.
    Select Copy List Item Extended, change the settings to be Copy item in Current Item to list at Fiscal Year 2013 folder url.
    Select Delete Item, change the settings to be Delete Item in Current Item.
    Select If current item field equals value, change the settings to be If Current Item: Created is greater than 7/1/2013.
    Select If current item field equals value, change the settings to be If Current Item: Created is less than 6/30/2014.
    Select Copy List Item Extended, change the settings to be Copy item in Current Item to list at Fiscal Year 2014 folder url.
    Select Delete Item, change the settings to be Delete Item in Current Item.
    Publish the workflow.
    Best regards.
    Thanks

  • Issues opening PDF files from SharePoint document library reader/pro 11.0.5

    Hello,
    We have a sharepoint 2010 enviroment and recently upgraded our Acrobat X11 installs ( both reader/std/pro) to version 11.0.5.
    We have a mixture of WIndows 7 32/64Bit IE 8 and IE 9 machines
    After upgrading to 11.0.5 when users click a pdf file in a SP document libary one of two things happens depending if they have the
    Adobe Reader Plugin Enabled or not
    If the Adobe Reader Plugin is enabled, they will not get prompted to run/save the pdf file and it will not open in a new tab in the browser
    If the Adobe Reader Plugin is disabled, they will get a popup window that has the correct URL to the PDF in the address bar but they will not be prompted to save or run the file.
    If they click in the addrss bar and press enter the pdf will then load in the external reader/acrobat application.
    This issue started with 11.0.5 updates, rolling people back to 11.0.4 fixes the issue.
    I have attempted everything I can think of including rebuilding new machines with our image.
    Has anyone see issues like this with the 11.0.5 update?

    If a bug is confirmed, a fix may be delivered in the next release (can't promise). For a similar issue caused by a Microsoft bug, see http://forums.adobe.com/message/6106294#6106294.
    Ben

  • How to transfer file from ipod touch to i tunes. i have files in my ipod , ut itunes is  new so its telling if u sync the ipod all the files will be replaced but no files in the itunes.. so kindly help me how to transfer the files  from i pod to itunesb

    how to transfer file from ipod touch to i tunes. i have files in my ipod , ut itunes is  new so its telling if u sync the ipod all the files will be replaced but no files in the itunes.. so kindly help me how to transfer the files  from i pod to itunes......

    Some of the information below has subsequently appeared in a document by turingtest2: Recovering your iTunes library from your iPod or iOS device - https://discussions.apple.com/docs/DOC-3991
    Your i-device was not designed for unique storage of your media. It is not a backup device and media transfer was designed for you maintaining a master copy of your media on a computer which is itself properly backed up against loss. Syncing is one way, computer to device, updating the device content to the content on the computer, not updating or restoring content on a computer. The exception is iTunes Store purchased content.
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer - http://support.apple.com/kb/HT1848 - only media purchased from iTunes Store
    For transferring other items from an i-device to a computer you will have to use third party commercial software. Examples (check the web for others; this is not an exhaustive listing, nor do I have any idea if they are any good):
    - Senuti - http://www.fadingred.com/senuti/
    - Phoneview - http://www.ecamm.com/mac/phoneview/
    - MusicRescue - http://www.kennettnet.co.uk/products/musicrescue/
    - Sharepod (free) - http://download.cnet.com/SharePod/3000-2141_4-10794489.html?tag=mncol;2 - Windows
    - Snowfox/iMedia - http://www.mac-videoconverter.com/imedia-transfer-mac.html - Mac & PC
    - iexplorer (free) - http://www.macroplant.com/iexplorer/ - Mac&PC
    - Yamipod (free) - http://www.yamipod.com/main/modules/downloads/ - PC, Linux, Mac [Still updated for use on newer devices? No edits to site since 2010.]
    - 2010 Post by Zevoneer: iPod media recovery options - https://discussions.apple.com/message/11624224 - this is an older post and many of the links are also for old posts, so bear this in mind when reading them.
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive - https://discussions.apple.com/docs/DOC-3141 - dates from 2008 and some outdated information now.
    Copying Content from your iPod to your Computer - The Definitive Guide - http://www.ilounge.com/index.php/articles/comments/copying-music-from-ipod-to-co mputer/ - Information about use in disk mode pertains only to older model iPods.
    Get Your Music Off of Your iPod - http://howto.wired.com/wiki/Get_Your_Music_Off_of_Your_iPod - I am not sure but this may only work with some models and not newer Touch, iPhone, or iPad.
    Additional information here https://discussions.apple.com/message/18324797

  • How to read the file from a folder.

    Hi All,
    How to read the file from a folder or directory from the non sap server / remote server.
    Regards
    Sathis

    open dataset filename for input in text mode
                         encoding default.
    filename is character type variable with the destination filename.
    Edited by: Jino Augustine on Apr 19, 2010 1:31 PM

  • Hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.

    hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.
    i do not have a mac home pc. just a regular pc

    I had the same problem after I gave my old iPad to my parents and tried to install Netflix. This is what you have to do:  Open iTunes on your computer, the one you sync your iPad to. Then go to iTunes Store and search for and download Netflix app. After you download it, if your iPad is set to download new purchases it may start downloading on your iPad. If so, tap and hold to delete the app (because it is trying to install the new version on the iPad) Next step, go to the App Store on your iPad and find Netflix and it should say install since you already purchased it on the computer. Tap to install, and it will say the version is not compatible, tap to download a previous version. Click that and it will install the older version!    One more thing, if and when you sync to your computer again it will say something like " Unable to install Netflix on your iPad" Just click the box to never remind you again, because it's trying to sync the newer Netflix app to your iPad, but it doesn't work so it displays the message. The old app will remain on the ipad. Hope this helps, good luck

  • HT6154 how to download the files from mail like gmail or yahoo or hotmail to my iphone 5s.I have not seen the option in my iphone 5s

    how to download the files from mail like gmail or yahoo or hotmail to my iphone 5s.I have not seen the option in my iphone 5s

    Download what files?
    What is the actual problem that is occurring?

  • Having trouble opening Crystal Report files from a document library

    I am trying to open Crystal Report .rpt files from a document library in either the native, client Crystal Reports software or in Crystal Reports Viewer. When I add the Crystal Report files to a document library and attempt to open them SharePoint displays
    a prompt asking me to save the file locally instead of opening the file. I have done a lot of research online and found several sites discussing similar scenarios, however, I have not been able to get these solutions to work. Here is a short list of sites
    I have referenced for possible solutions:
    http://naadydev.blogspot.com/2013/03/crystal-report-viewer-sharepoint-2010.html?showComment=1383339860122
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/52aabf2d-10dc-424c-bd50-124fc972a9b9/crystal-report-viewer-integration-with-sharepoint-2010?forum=sharepointgeneralprevious
    http://www.codeproject.com/Articles/42731/Crystal-Reports-WebPart-for-SharePoint
    Here are the steps I have done to try to get the .rpt files to open:
    Added the Crystal Report extension .rpt as a MIME type
    Installed the Visual Studio 2012 Crystal Reports Viewer toolbar
    Installed the 64-bit Crystal Reports runtime
    I have also created a solution file based off the Code Project site which partially works, but not quite right. In this project I have created a document library called "Crystal Reports rpt Files" and deployed the solution file to a site. When
    I open the Web Part Maintenance Toolbar I can see the selected .rpt file in the drop-down, but no Crystal Report file is displayed on the page itself.
    I am not sure what I am doing wrong. Does anyone have experience working with Crystal Reports and SharePoint 2013 (or earlier versions) that could lend some advice?
    Thank you,
    Alex

    We are having the exact same issue, has anyone resolved this yet?

  • How to copy a folder from one document library to another document library ?

    How to copy a folder from one document library to another document library by programmtically?
    Samarendra Swain
    Team Sharepoint
    www.manuhsolutions.com

    You can use the SPFolder.CopyTo method.
    public static void CopyFolder()
    SPFolder folder = null;
    using (SPSite site = new SPSite("http://basesmcdev2/sites/tester1"))
    using (SPWeb web = site.OpenWeb())
    folder = web.GetFolder("shared%20documents/newfolder");
    folder.CopyTo("tester4/newfolder");
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.copyto.aspx
    certdev.com

  • How to grant anonymous access on sharepoint document library/list only not for web application

    Hello
    How to grant anonymous access on sharepoint document library/list only not for web application.I have claim based sharepoint site and has to be but i want to grant access on document library/list only.Is this possible?
    Thanks
    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

    As i am using following code
    SPSite site = SPContext.Current.Site;
                SPWeb web = SPContext.Current.Web;
                SPSecurity.RunWithElevatedPrivileges(delegate()
                    using (SPSite ospSite = new SPSite(site.ID))
                        using (SPWeb webs = ospSite.OpenWeb(web.ID))
                            // Enable anonymous access on web application
                            webs.AllowUnsafeUpdates = true;
                            SPUrlZone urlZone = SPUrlZone.Default;
                            SPWebApplication specifiedWebApplication = ospSite.WebApplication;
                            SPIisSettings iisSettings = specifiedWebApplication.IisSettings[urlZone];
                            //iisSettings.AuthenticationMode = AuthenticationMode.Windows;
                            iisSettings.AllowAnonymous = true;                       
                            specifiedWebApplication.Update();
                            // Get document library collection here and fetch all the document urls
                            SPDocumentLibrary docLib = (SPDocumentLibrary)web.Lists["Documents"];
                            if (docLib != null)
                                docLib.BreakRoleInheritance(true, false);
                                docLib.AllowEveryoneViewItems = true;
                                docLib.AnonymousPermMask64 = SPBasePermissions.ViewPages | SPBasePermissions.OpenItems | SPBasePermissions.ViewVersions
                                    | SPBasePermissions.Open | SPBasePermissions.UseClientIntegration | SPBasePermissions.ViewFormPages | SPBasePermissions.ViewListItems;
                                //docLib.AnonymousPermMask64 = SPBasePermissions.EmptyMask;
                                docLib.Update();
    Should working but getting access denied......i am totally stuck at this point.
    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

  • How to delete the files from iPhone before selling?

    How do I delete the files from my old iPhone4 before selling?

    Hey adhot,
    Before selling your iPhone, you'll want to follow these directions:
    Before you sell or give away your iOS device, make sure that you have removed all of your personal information. Follow these steps to protect your data and get your device to its factory default state for the new owner:
    Back up your device.
    Go to Settings > General > Reset, then tap Erase All Content and Settings.
    This will completely erase your device and turn off iCloud, iMessage, FaceTime, Game Center, and other services.
    If you are using iOS 7 and have Find My iPhone turned on, your Apple ID and password will be required. After you provide your password, the device will be erased and removed from your account so that the next owner can activate it.
    Contact your carrier for guidance on transferring service to the new owner.
    When the device is turned on for the first time by the new owner, Setup Assistant will guide them through the setup process.
    Important: Do not manually delete contacts, calendars, reminders, documents, photo streams, or any other iCloud data while signed in to your iCloud account, or the content will also be deleted from the iCloud servers and all of your iCloud devices.
    via: What to do before selling or giving away your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT5661
    Have a great day,
    Delgadoh

  • How to filter the file type and size when uploadind files into APEX

    Hi,
    I was wondering how I can do to validate the size of a file, before moving it to my table ? I'd like to filter the file type, but for this one, I think I can use regular expressions in a validation process.
    I don't know if there is a way to read the file size even before sending it into the temporary file table.
    Thank you
    Leinad

    Hello Leinad,
    AFAIK, you have to create an APEX validation (PL/SQL returns Boolean or Returns error text), which will query the file details from apex_flow_files table. Here you can get filetype and size etc.
    So just validate and if any validation fails, then delete the file from apex_flow_files and riase error message.
    Regards,
    Hari
    P.S. Please note that, if there are other apex validations on your page and if they fail, still apex will load the file into apex_flow_files table. So it's good idea to create a validation (PL/SQL) which will fire (condition) when inline validation errors occured. Make sure that this is the LAST validation on your page in sequence. And here you can write code to delete the file from apex_flow_files table.
    Edited by: Hari_639 on Sep 20, 2012 10:09 PM

  • How to upload the file from website into R/3

    Dear Experts,
              I want to post the data in r/3 using bdc.but flat file is available in some website for eg.'www.sap.com'.how to retrieve the flat file from the website and how to upload the data from website to r/3.
    It is very urgent please help me.
    Thanks & Regards,
    Ashok.

    Hi Ashok,
        We cannot directly pulled data from website. we need to activate webservices and rfcs. Better you could asked to your Basis guy that he knows or not. If not then do sdn you will get the appropriate answer. I can only say that its possible and we can download from website.
    Regds,
    Rakesh

  • How to delete the files from server through OAF page

    Hi All,
    I have a requirement in which i am creating files on server through my CO code.
    Now once the page is rendered, i want to delete the files from the server.
    Just wondering how can we achieve this.
    Kindly advice!
    Thanks,
    Sachin

    Hi Sachin
    all the methods in the processRequest() are called during loading of the page.
    all the methods in the processFormRequest() are called during any action events on the page.
    So Use the method in processFormRequest() : write a method in
    that on which action you want to delete the file.
    regards
    sridhar

Maybe you are looking for

  • Standard smart forms

    hi All, Pls give me the details that how to use system defined smart forms and how to copy and change standard smart forms in SAP 4.7EE Thanks, Nitin

  • Free Trial Download

    Every time i download it says error 101...why doesn't it download? (Adobe audition is for editing audio)

  • Panic(cpu 13 caller Crash. Trying to understand what is causing?

    Ok, so I have a Mac Pro 8 Core Mid 2010 running 32GB. For some time now I have been having crashes when I run Adobe Media Compressor. This only happens when I run a very heavy load. I have removed my ram and reseated, cleaned out the motherboard. I h

  • Can I download Lion onto more than one computer?

    I have an iMac and a MacBook Pro.  If I purchase a Lion upgrade and download it via the internet to my iMac do I have to purchase a second download for my MacBook Pro??  Or, would I be better off buying a Lion CD and using it to upgrade both of my co

  • Weblogic Log Files

    Hi, Can anybody explain What is the difference between server.log and server.out files? Thenks for your help.