how do we validate a file while saving in a invalid drive ?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mohamed_Ibrahim
Posted On:   Friday, March 8, 2002 02:40 AM


how do we find whether the given directory structure is a valid one or not.
eg. if there are only c:, and d:, I am trying to save the file in k:, how do we find whether it is a valid drive or not.

Re: how do we validate a file while saving in a invalid drive ?

Posted By:   John_Zukowski  
Posted On:   Sunday, March 24, 2002 05:53 PM

File.listRoots() returns that set of valid top-level drives/directories.

Re: how do we validate a file while saving in a invalid drive ?

Posted By:   Anonymous  
Posted On:   Friday, March 8, 2002 05:28 AM

I would say that since the concept of drive is something that is not platform indipendent, you can create a File object with the path of the location where you want to store the file, and verify if it's a directory:

File dir = new File("K:/");
if (dir.isDirectory()) {
// yes, it's a valid directory
} else {
// nope, not a valid directory
}

Regards
About | Sitemap | Contact