Hi,
here's some code
FileInfo fileInfo = new FileInfo("c:
myfile.txt");
System.out.println("fileInfo.toString() " + fileInfo.toString());
System.out.println("fileInfo.getFileName() " + fileInfo.getFileName());
System.out.println("fileInfo.getLastModified() " + fileInfo.getLastModified());
System.out.println("fileInfo.getSize() " + fileInfo.getSize());
System.out.println("fileInfo.attributes() " + fileInfo.getAttributes());
Here's the output
fileInfo.toString() c:\myfile.txt
fileInfo.getFileName() c:\myfile.txt
fileInfo.getLastModified() 0
fileInfo.getSize() 0
fileInfo.attributes() 0
The last three values are wrong.
Anything wrong with this code ?
Thank you
Andre Tessier
Hi,
The FileInfo class is not supposed to be used in such way, because it is rather the storage of a file information then the utility for retrieving it.
You can find the source code for this class in the sources of WinPack library. This class is used by the FileSystemWatcher class, in both its (Win9xWatcherStrategy and WinNTWatcherStrategy) strategies for storing the file system information.
To retrieve a file information (such as lastModified etc.) you can use the standard Java java.io.File class. If you need to get the extended file information, which is not provided by the File class, you can use the com.jniwrapper.win32.io.FileSystem class from WinPack library. It allows to get/set all file attributes, get free disk space and so on.