3

In Windows Explorer a file has three dates: "creation date", "last modified date" and "acquisition date?" (in Italian it is called "data acquisizione". It is important for me because it is the exact date at which, e.g., a photo is taken (the other two dates change upon trasmission, e.g. when sending zipped files. I know functions to get "creation date" and "last modified date", but I do not how to get the "acquisition date?" of a file. Can you help me? All the best, Ovidio Crocicchi

Hot Licks
  • 47,103
  • 17
  • 93
  • 151

2 Answers2

1

You are trying to obtain a metadata that is only contained in image files, like JPEG.

I had the same problem and I have not found a solution using standard API. Eventually I solve the problem using the metadata-extractor library that can extract EXIF metadata from image files. The library is really user-friendly, this is the code I used:

File file = new File("C:\\myFile.jpg");
Metadata metadata = ImageMetadataReader.readMetadata(file);
Date acquisitionDate = metadata.getDirectory(ExifIFD0Directory.class)
    .getDate(ExifIFD0Directory.TAG_DATETIME);
Alberto
  • 1,569
  • 1
  • 22
  • 41
0

Windows files have 3 file times, all are exposed in the windows API.

Creation Date, Modified Date, Last Accessed Date.

Any other date is an extended property.

There are S/O articles on reading and setting extended properities via C# using the .net framework.

You should also be able to right click on a file in explorer, select properties from the context menu and see all of the extended properties -- c.f. the MS article Retrieving Extended File Properties

ADDED

You mention that these attributes are not copied when the file is copied. This is a very common problem with these extended attribute as many programs do not copy these extended properties when copying a file because they are only loosely coupled to the file and are not copied automatically whenever the file is copied -- as such, they should not rely on them to store important information, and because of this, they are likely to be poorly supported essentially forever -- since programmers won't rely upon them for important information.

Depending upon the target filesystem, there may be no way to copy these extended attributes at all. E.g. drives using FAT32 (common for USB drives).

Community
  • 1
  • 1
Gary Walker
  • 8,831
  • 3
  • 19
  • 41