• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to search specific file

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am devloping one application in which I want to know the path of particular file, suppose i want to know the path of Apache.exe, where this file is saved.
Thanks
Puneet
 
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
you can first search the "default" locations where this file could be, if this fails search the whole disk or ask user to point to the file.
i dont see another way to do this, i might be wrong ?
is this enough or do you need more infos on how to handle files ?
karl
 
Puneet1 Khurana
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karl,
thanks for your response, I have solved this problem. I used File class for this, firstly I saw number of drives in the system by listRoots(), than see all the files in folders and sub-folders in these drives and comapre these files with name of file. Than I got absolute path of this file.
Once again Thanks
Puneet
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the code that can help u out .....
static void Tri(File file)
{
if(!file.isDirectory())
{
return;
}
File fi[]=file.listFiles();
for(int i=0; i<fi.length; i++)>
{
list.add(fi[i].getPath());
Tri(fi[i]);
}
}
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic