• Post Reply Bookmark Topic Watch Topic
  • New Topic

file path  RSS feed

 
marys joseph
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any way to find a path of a file with out actually creating it? for example I need to find where outlook.exe is located in clients system? how can i do it?
thanks,
 
clio katz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have to create the file because

File file = new File("blah");

just gives you a handle to a - potentially nonexistent - file. You can use 'file.exists()' to determine if it's a real file.

if i had to look for a MS app, i would

(a) first take a stab a finding it in it's default install dir
or any reasonable approximation

since it's a Win app, you won't need to deal w multi-platform issues

(b) try searching along the PATH (env var)

(c) you may want to also check if MS leaves post-install markers around,
or if you can look it up in the registry (JNI?), or if you have some
special file extension mapping or "content type" you can trace back
to the path

Ken Krebs mentioned this API in a previous post

(d) if (a) through (c) fail, the app is probably not there or
not being used ...

BUT finally .. for the VERY UNATTRACTIVE Option:
if all else fails, you can start with the root dir and work your
way down the directory tree (argh). There are undoubtedly some
shortcuts available, but if you have to traverse the whole tree,
you could create some threads to help along the way.

You could start your search method with the test 'file.isDirectory()',
then gather the list of files in the dir with
File files[] = file.listFiles();

and so on. (hard drive selection omitted for simplicity.)

not sure if this helps but ...

hth
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by clio katz:
since it's a Win app, you won't need to deal w multi-platform issues


just to be precise: since we have wine, a win-emulator, you might deal with multi-platform issues.

If you want to delete outlook.exe, you even don't need wine and have to deal with multi-platform issues as well
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!