ID: Q191936
The information in this article applies to:
Java's file.list() method does not list files/directories on Windows 95 and Windows 98 with Virtual Machine for Java 2829 when file parameter is specified as File("C:\\") for example. This is true for any path ending with a "\\" specified as a parameter to File, irrespective of whether the program is an applet or an application.
The workaround is to append a period "." to the parameter as in File("C:\\.").
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
1. Create the following Java application Test.java:
// Test.java
import java.io.*;
public class Test
{
public static void main(String[] args)
{
File _file = null;
_file = new File("c:\\");
String files[] = _file.list();
for (int i=0; i<files.length;i++)
System.out.println(files[i]);
}
}
2. Generate a class file:
jvc Test.java
3. Run the application:
jview Test
For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following page on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/
http://support.microsoft.com/support/java/
(c) Microsoft Corporation <year>, All Rights Reserved. Contributions by
Mohan Ananthakrishnan,
Microsoft Corporation.
Additional query words: Java VM File
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbpending
Last Reviewed: September 1, 1998