How to find files and subdirectories in a directory

can anyone tell me how to find files and subdirectories in a directory .

Here's a code snippet,
http://javaalmanac.com/egs/java.io/TraverseTree.html

Similar Messages

  • How to find folders and files by its partial name c#

    in a specific folder of my hard drive i have stored many other sub folder and files. now i want to list those folders and files name by their partial name.
    for example
    c webapi xx folder
    c mvctutorial xx folder
    done webapi xx folder
    webapi done folder
    webapi.zip file
    mvc.iso file
    now when i like to search by partial name webapi then i want to get list of files and folders name which has webapi word. i want to show their full folder or file name in grid with their full path and size. like below way.
    Name Type location Size
    c webapi xx folder c:\test1 2 KB
    c mvctutorial xx folder c:\test3 3 KB
    done webapi xx folder c:\test1 11 KB
    webapi done folder c:\test1 9 KB
    webapi.zip file c:\test1 20 KB
    mvc.iso file c:\test4 5 KB
    i got a sample code which look like for finding files but the below code may not find folder. so i am looking for a sample code which will find files and folders too. so guide me to solve my issue.
    the below sample code will find files but not sure does it find files by partial name. here is the code. i am not before dev environment. so could not test the below code.
    find files code
    static void Main(string[] args)
    string partialName = "webapi";
    DirectoryInfo hdDirectoryInWhichToSearch = new DirectoryInfo(@"c:\");
    FileInfo[] filesInDir = hdDirectoryInWhichToSearch.GetFiles("*" + partialName + "*.*");
    foreach (FileInfo foundFile in filesInDir)
    string fullName = foundFile.FullName;
    Console.WriteLine(fullName);

    See code below
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    namespace ConsoleApplication1
    class Program
    static void Main(string[] args)
    string partialName = "webapi";
    DirectoryInfo hdDirectoryInWhichToSearch = new DirectoryInfo(@"c:\");
    FileInfo[] filesInDir = hdDirectoryInWhichToSearch.GetFiles("*" + partialName + "*.*");
    foreach (FileInfo foundFile in filesInDir)
    string fullName = foundFile.FullName;
    Console.WriteLine(fullName);
    DirectoryInfo[] foldersInDir = hdDirectoryInWhichToSearch.GetDirectories("*" + partialName + "*.*");
    foreach (DirectoryInfo foundFolder in foldersInDir)
    string fullName = foundFolder.FullName;
    Console.WriteLine(fullName);
    // or
    List<string> filesInDir2 = hdDirectoryInWhichToSearch.GetFiles("*" + partialName + "*.*").Select(x => x.FullName).ToList();
    filesInDir2.AddRange( hdDirectoryInWhichToSearch.GetDirectories("*" + partialName + "*.*").Select(x => x.FullName).ToList());
    foreach (string filesFolders in filesInDir2)
    Console.WriteLine(filesFolders);
    jdweng

  • Something was hidden in a download and now these double green underlined hyperlinks show up everywhere, and pop ups too whenever I click on ANYTHING. I can't figure out how to find it and get rid of it.

    Something was hidden in a download and now these double green underlined hyperlinks show up everywhere, and pop ups too whenever I click on ANYTHING. I can't figure out how to find it and get rid of it.

    You installed the "DownLite" trojan, perhaps under a different name. Remove it as follows.
    Malware is constantly changing to get around the defenses against it. The instructions in this comment are valid as of now, as far as I know. They won't necessarily be valid in the future. Anyone finding this comment a few days or more after it was posted should look for more recent discussions or start a new one.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    /Library/LaunchAgents/com.vsearch.agent.plist
    Right-click or control-click the line and select
    Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item named "VSearch" selected. Drag the selected item to the Trash. You may be prompted for your administrator login password.
    Repeat with each of these lines:
    /Library/LaunchDaemons/com.vsearch.daemon.plist
    /Library/LaunchDaemons/com.vsearch.helper.plist
    /Library/LaunchDaemons/Jack.plist
    Restart the computer and empty the Trash. Then delete the following items in the same way:
    /Library/Application Support/VSearch
    /Library/PrivilegedHelperTools/Jack
    /System/Library/Frameworks/VSearch.framework
    Some of these items may be absent, in which case you'll get a message that the file can't be found. Skip that item and go on to the next one.
    From the Safari menu bar, select
    Safari ▹ Preferences... ▹ Extensions
    Uninstall any extensions you don't know you need, including any that have the word "Spigot" in the description. If in doubt, uninstall all extensions. Do the equivalent for the Firefox and Chrome browsers, if you use either of those.
    This trojan is distributed on illegal websites that traffic in pirated movies. If you, or anyone else who uses the computer, visit such sites and follow prompts to install software, you can expect much worse to happen in the future.
    You may be wondering why you didn't get a warning from Gatekeeper about installing software from an unknown developer, as you should have. The reason is that the DownLite developer has a codesigning certificate issued by Apple, which causes Gatekeeper to give the installer a pass. Apple could revoke the certificate, but as of this writing, has not done so, even though it's aware of the problem. This failure of oversight is inexcusable and has compromised the value of Gatekeeper and the Developer ID program. You can't rely on Gatekeeper alone to protect you from harmful software.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • Find File and Spotlight not working....

    Hi all,
    Today, I used the find file command to search for survey I needed to print out. I searched for "survey" and nothing was found. I did the same thing in spotlight with the same results. I then searched through folders (the horror) and found the file I was looking for. After opening the file, both "find" and spotlight were able to find the document. A couple of hours ago, I did a search for "memo" - I've got many documents with the word memo in it - both find file and spotlight came up with no results. I did a quick search in the spotlight topic and someone suggested using Yasu to run all of the maintenances - same results. Does anyone know how to reset the index file, or whatever file OS X uses? I'm currently running OS 10.4.5.
    Bryan

    692/3138
    Hi Bryan,
    Even after so many threads, ideas and turnarounds found on these very Forums by Francine Schwieder and many other geniuses, discussing its doubtful behaviours and trying to make it work better,
    personally I don't think I can trust it anymore, rely on it to find something and to positively conclude it's not here if it doesn't find it.
    Even if one day I see it finds invisible files at last.
    That's why I use EasyFind.
    EasyFind always finds everything, just like Panther's Find (⌘F) feature used to, because it uses the same kind of indexing.
    Your problem looks like you just didn't give it enough time to index, but anyway, can you rely on it anymore after that?
    On my computer, EasyFind has always been stable, problem-free, and unfortunately a little slow.
    Enjoy (the other good aspects of) Tiger!
    Axl

  • HT3231 how to find file after using migration

    how to find files after migration has finished

    If you don't have any file you need in your old account, open System Preferences > Users and Groups and delete the old user. If not, I recommend you to migrate your files of your old account to the new one using Shared folder or an USB drive

  • How to find users and group in sun box

    Please adivce How to find users and group in sunsolaris
    Thanks in advance

    We can get all the group details from /etc/group file .
    Similarly user details can be found in /etc/passwd .

  • How to find 11i and r12 applications characterset

    Hi,
    How to find 11i and r12 applications characterset not of database only applications,What is IANA characterset asked in rapid install?How to find IANA character set in 11i and r12
    Regards

    Hi,
    How to find 11i and r12 applications characterset not of database only applicationsAs applmgr user, source the application env file and issue "echo $NLS_LANG".
    You can also get it from the application context file (search for <NLS_LANG oa_var="s_nlslang">).
    What is IANA characterset asked in rapid install?How to find IANA character set in 11i and r12This is documented in the installation manual.
    The IANA (Internet Assigned Numbers Authority) character set is the Internet-assigned standard character set name used by the Web server. See http://www.iana.org/assignments/character-sets for more information.
    Regards,
    Hussein

  • How to find classtype and class for a material.

    Hi,
    How to find classtype and class for a material.
    which table contains this data.
    Thanks
    Kiran

    Hi Kiran,
    Check below sample code. Use this BAPI which will give all info about the class for the material.
      DATA:      l_objectkey_imp    TYPE bapi1003_key-object
                                         VALUE IS INITIAL.
      CONSTANTS: lc_objecttable_imp TYPE bapi1003_key-objecttable
                                         VALUE 'MARA',
                 lc_classtype_imp   TYPE bapi1003_key-classtype
                                         VALUE '001',
                 lc_freight_class   TYPE bapi1003_alloc_list-classnum
                                         VALUE 'FREIGHT_CLASS',
                 lc_e               TYPE bapiret2-type VALUE 'E',
                 lc_p(1)            TYPE c             VALUE 'P',
                 lc_m(1)            TYPE c             VALUE 'M'.
      SORT i_deliverydata BY vbeln posnr matnr.
      CLEAR wa_deliverydata.
      LOOP AT i_deliverydata INTO wa_deliverydata.
        REFRESH: i_alloclist[],
                 i_return[].
        CLEAR:   l_objectkey_imp.
        l_objectkey_imp = wa_deliverydata-matnr.
    *Get classes and characteristics
        CALL FUNCTION 'BAPI_OBJCL_GETCLASSES'
          EXPORTING
            objectkey_imp         = l_objectkey_imp
            objecttable_imp       = lc_objecttable_imp
            classtype_imp         = lc_classtype_imp
    *   READ_VALUATIONS       =
            keydate               = sy-datum
            language              = sy-langu
          TABLES
            alloclist             = i_alloclist
    *   ALLOCVALUESCHAR       =
    *   ALLOCVALUESCURR       =
    *   ALLOCVALUESNUM        =
            return                = i_return
    Thanks,
    Vinod.

  • HT2509 Hello I wonder if anyone knows how to find, download and install a suitable IPA (phonetics) font for the Mac Air? I need to be able to use a pop up window of fonts.

    Hello I wonder if anyone knows how to find, download and install a suitable IPA (phonetics) font for the MacBook  Air? I need to be able to use a pop up window of fonts.

    Unless you've done anything to change it, Google keeps every email that ever passes through their server in your All Mail folder/mailbox/label. Even if you delete stuff, they hold onto it, there. You have to go out of your way to actually delete anything permanently.

  • HT1848 I rented four movies on my mac and then transfered them to my iPad, i then did an update to my iPad, now the rentals are not on my ipad nor my mac. I did not watch them and I was charged for them. How do find them and transfer back on my iPad

    I rented four movies on my mac and then transfered them to my iPad, i then did an update to my iPad, now the rentals are not on my ipad nor my mac. I did not watch them and I was charged for them. How do find them and transfer back on my iPad

    If you moved them to your iPad then they will have been removed from your Mac.  If they are no longer in the iPad's Videos app following the update then you will need to try contacting iTunes support and see if they will let you re-download them : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • What is the name of the folders which are your backup of Itunes library? I am recovering from a virus, have no workable desktop in Win XP, but can search and find files and folders. I would like to move these backup files to a new computer

    what is the name of the folders which are the backup of Itunes library? I am recovering from a virus, have no workable desktop in Win XP, but can search and find files and folders. I would like to move these backup files to a new computer, authorize it and sync with Iphone 3Gs and Ipod 5th gen.
    I

    I second the whole iTunes folder approach.
    If for some reason you have split the media folder from the library files then the media folder needs to restored to the same path it used to have while the library files can be copied into the music folder of your new profile.
    If in dobut, backup up the entire Documents and Settings folder before wiping the infected drive, but be selective about what you restore as many viruses drop active components capable of reinfecting the compuer in the temp folders and internet caches. It is much easier to backup more than you need than to discover after the fact that you no longer have access to some vital project you'd been storing in a folder on the desktop.
    tt2

  • How to find list and cost price in MM module

    Hi
    Can any one help me in how to find List and cost price in MM module for pricing.
    thank you.
    David

    hi Saquib Khan
    Many thanks Saquib Khan for ur reply. Actually iam trying to create a report which displays material number, material description, plant, product hierarchy, cost and list price, based on the selection criteria of a range of materials, plant and also product hierarchy.
    If u want to share any information.It would be much better for me.Like iam learning SAP.
    thanks.

  • HOW TO FIND WF_ITEM_TYPE AND WF_ITEM_KEY FOR PO

    제품 : MFG_PO
    작성날짜 : 2003-05-14
    HOW TO FIND WF_ITEM_TYPE AND WF_ITEM_KEY FOR PO
    ===============================================
    PURPOSE
    This solution is for Oracle Purchasing 11 and higher
    Explanation
    1. Start a SQL*Plus session using the APPS schema.
    2. Run the following script and enter the Purchase Order number that is stuck
    in process when prompted for the PO_NUMBER:
         SELECT WF_ITEM_TYPE, SUBSTR(WF_ITEM_KEY,1,25) "WF_ITEM_KEY"
         FROM PO_HEADERS_ALL
         WHERE AUTHORIZATION_STATUS='IN PROCESS'
         AND SEGMENT1='&PO_NUMBER';
    3. If more than one row is returned, then run the following script and only
    refer to the row that contains the OPERATING_UNIT_NAME that equals the
    operating unit name tied to the responsibility used when the Purchase Order was
    discovered as being stuck in process.
         SELECT SUBSTR(WF_ITEM_TYPE,1,12) "WF_ITEM_TYPE",
         SUBSTR(WF_ITEM_KEY,1,15) "WF_ITEM_KEY",
         SUBSTR(NAME,1,35) "OPERATING_UNIT_NAME"
         FROM PO_HEADERS_ALL PA, HR_ORGANIZATION_UNITS OU
         WHERE PA.ORG_ID=OU.ORGANIZATION_ID
         AND AUTHORIZATION_STATUS='IN PROCESS'
         AND SEGMENT1='&PO_NUMBER';
    Example
    Reference Documents
    -------------------

    Hi Kishore,
    Welcome to SCN!
    to find the sales order from Purchase order , go to SE16, Enter the table name as VBAK and press Enter.
    In BSTNK field of VBAK, Enter the Purchase order number. System will return you corresponding sales order.
    Hope this will help you.
    Regards,
    Nikhil

  • How do I file and manage documents?

    How do I file and manage documents?
    New to iPad, very impressed.
    I want to stop using a PC and run my small B&amp;B using the iPad and iPhone
    Thanks

    The iPad does not include a file management system in the way that a PC does. You may want to think twice about giving up your PC. The iPad is not meant to completely replace a PC.

  • So someone took my ipod 4g and who ever took it turned it off and i dont know how to find it and i really want it back, what should i do?

    so someone took my ipod 4g and who ever took it turned it off and i dont know how to find it and i really want it back, what should i do?

    lost/stolen                                      
    No app on the iPod is required.                            
    - If you previously turned on FIndMyiPod on the iPod in Settings>iCloud and wifi is on and connected, on a computer browser go to iCloud: Find My iPhone, sign in and go to FIndMyiPhone. If the iPod has been restored it will never show up.
    - You can also wipe/erase the iPod and have the iPod play a sound via iCloud.
    - If not shown, then you will have to use the old fashioned way, like if you lost a wallet or purse.
    - Change the passwords for all accounts used on the iPod and report to police
    - There is no way to prevent someone from restoring the iPod (it erases it) using it unless you had iOS 7 on the device. With iOS 7, one has to enter the Apple ID and password to restore the device.
    - Apple will do nothing without a court order                                                
    Reporting a lost or stolen Apple product                                               
    - iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number

Maybe you are looking for