Hi All,
Sir, i am working in a java application.On that application i have to access files from "My Documents". The problem is coming with windows version when i am using windows 7, it can be accessed as "Documents" folder but for windows XP it is "My Documents".
I am writing following code to access files from "Documents" folder in windows 7 .
public static void main(String[] arr)
{
try{
String source = System.getProperty("user.home")+ File.separator + "Documents";
File[] Files = new File(source).listFiles();
System.out.println(Files.length);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
and for Windows Xp
public static void main(String[] arr)
{
try{
String source = System.getProperty("user.home")+ File.separator + "My Documents";
File[] Files = new File(source).listFiles();
System.out.println(Files.length);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
Please could you suggest me a generic method, which can be applied for all the versions of Windows.
Please send me your valuable answers and suggestions.
Thanks