Results 1 to 2 of 2

Thread: How to get the list of Drives in Windows

  1. #1
    Join Date
    May 2010
    Posts
    1

    How to get the list of Drives in Windows

    Hi all,

    I'm new to perl,
    In one of my requirement, I need to find a particular directory. this directory may be in any drive.

    -> How to get the list of Drives in Windows( C:/ , D:/ etc..)
    -> After this My Perl script need to get into each drive and search a particular dir.
    -> If it is found, then the script need to print the whole path of the dir.

    E.g:-

    Input : "Logfile\testfindDir" # this is the dir the script need to find.

    output: "D:\\desktop\Logfile\testfindDir"



    Thanks
    Tpr

  2. #2
    Join Date
    Dec 2009
    Posts
    292

    Directory listing under windows using java

    Hello,
    I have no much idea how to do this in perl, but if you need the logic then I have a code where it is done in java.
    Here is the code
    Code:
    import java.io.*;
    
    public class  DirListing{
      private static void dirlist(String fname){
        File fl = new File(fname);
        String[] str = fl.list();
        if(str == null){
          System.out.println("Specified directory does not exist or is not a directory.");
          System.exit(0);
        }else{
          for(int x = 0; x < str.length; x++){
            String fileName = str[x];
            System.out.println(fileName);
          }
        }
      }
      public static void main(String[] args){
        switch(args.length){
          case 0: System.out.println("Directory has not mentioned.");
              System.exit(0);
          case 1: dirlist(args[0]);
              System.exit(0);
          default : System.out.println("Multiple files are not allow.");
                System.exit(0);
        }
      }
    }

Similar Threads

  1. Eset NOD32 lock sata drives while using external drives
    By Ecchumati in forum Networking & Security
    Replies: 9
    Last Post: 24-11-2011, 02:13 PM
  2. Replies: 1
    Last Post: 30-09-2011, 12:00 PM
  3. How to get list of drives using DOS command on Windows Xp
    By McGrawh in forum Operating Systems
    Replies: 3
    Last Post: 12-10-2009, 06:13 PM
  4. Transcend Pen Drives Price List in India
    By Kelewyn in forum Portable Devices
    Replies: 2
    Last Post: 30-07-2009, 08:52 AM
  5. Replies: 1
    Last Post: 21-09-2008, 09:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,522,383.76018 seconds with 16 queries