How do I search for a file in a folderand its subfolders?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aleplgr
    New Member
    • Aug 2007
    • 19

    How do I search for a file in a folderand its subfolders?

    Hi! I'm trying to open a pdf file and this way works fine when the pdf it's in C:
    try
    {
    Runtime.getRunt ime().exec("run dll32 url.dll,FilePro tocolHandler " + "c:\\tuto.pdf") ;
    }
    but now I don't know the tuto.pdf path, I know it looks like this:
    SOMETHINGHERE \ MyApplication\T otorials\tuto.p df, but how could I find the SOMETHINGHERE part of the path?
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    Originally posted by aleplgr
    Hi! I'm trying to open a pdf file and this way works fine when the pdf it's in C:
    try
    {
    Runtime.getRunt ime().exec("run dll32 url.dll,FilePro tocolHandler " + "c:\\tuto.pdf") ;
    }
    but now I don't know the tuto.pdf path, I know it looks like this:
    SOMETHINGHERE \ MyApplication\T otorials\tuto.p df, but how could I find the SOMETHINGHERE part of the path?
    This is not a Java or a PDF question is it? How you find the path of a file? You must know where it is to begin with, right? Otherwise this is like asking "how long is a piece of string?"

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      Crossposted: http://forum.java.sun.com/thread.jspa?threadID=5261595

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by aleplgr
        Hi! I'm trying to open a pdf file and this way works fine when the pdf it's in C:
        try
        {
        Runtime.getRunt ime().exec("run dll32 url.dll,FilePro tocolHandler " + "c:\\tuto.pdf") ;
        }
        but now I don't know the tuto.pdf path, I know it looks like this:
        SOMETHINGHERE \ MyApplication\T otorials\tuto.p df, but how could I find the SOMETHINGHERE part of the path?
        You could transform this problem to "How do I search for a file in a folder and it's subfolders".

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          Originally posted by r035198x
          You could transform this problem to "How do I search for a file in a folder and it's subfolders".
          Yesssssssssssss sssss

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by BigDaddyLH
            Yesssssssssssss sssss
            Argh, I didn't mean you SmallDaddy ...

            Comment

            • aleplgr
              New Member
              • Aug 2007
              • 19

              #7
              Yes, you are right, thanks, the file I'm searching it's located in a fixed folder in MyApplication folder, but MyApplication folder will be distributed to other users that I don't know where are going to locate it. To find the path to MyApplication folder I'm using this:
              String wd = System.getPrope rty("user.dir") ;
              and it's working ok, what do you think about it?
              Thanks

              Comment

              • BigDaddyLH
                Recognized Expert Top Contributor
                • Dec 2007
                • 1216

                #8
                Originally posted by aleplgr
                Yes, you are right, thanks, the file I'm searching it's located in a fixed folder in MyApplication folder, but MyApplication folder will be distributed to other users that I don't know where are going to locate it. To find the path to MyApplication folder I'm using this:
                String wd = System.getPrope rty("user.dir") ;
                and it's working ok, what do you think about it?
                Thanks
                If directory MyApplication is in the user's home directory that works. If not, it doesn't.

                Comment

                Working...