Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1063965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:51:41+00:00 2026-05-16T18:51:41+00:00

Sir, i am working in a java application.On that application i have to access

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:51:42+00:00Added an answer on May 16, 2026 at 6:51 pm

    You can check for the operating system version and then use that to map the proper file name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a simplified version of a problem I'm working on: I have a bunch
Respected Sir! As i have not learnt java yet but most people say that
I am working on a project that uses MDI form in java. I have
$(.menu-container).animate({top:25px}); $(.menu-container).animate({top:-900px}); $(.windows-container).animate({top:-730px}); hello sir.. i got a problem on queue in jquery.. what
Sir, I am developing an application for a device running WINDOWS CE 5.0. I
Sir, I am doing the task on fetching the contents from the xml file.I
Sir, I am having some problem regarding database in SQL Server. My project is
Respected sir/madam, I have a fortran exe which takes a input file and produces
Hello sir i send the arraylist through url pass from android to php all
Respected Sir, Here i am using the uiimagepickercontroller to open the camera and taking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.