Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to output date created and date modified?
#11
I am so sorry somehow i forgot to add the release of resources to the code.

Function GetDateTaken2
Code:
Copy      Help
out
int i ii nt
ARRAY(str) a
GetFilesInFolder a "$Desktop$\TEST\" ""
a.sort(8)
for ii 0 a.len
,Dir d.dir(a[ii])
,if(d.FileSize > 0);;error handing to make sure file is not empty(if we try to access empty file, the function will error and end)
,,str path=d.FullPath
,,out path;;comment out or remove this line .Only here to show filename and path
,,str R=CsFunc("" path)
,,if(R !="No MetaData found")
,,,DateTime dt
,,,ARRAY(str) arr
,,,nt=tok(R arr -1 " ")
,,,_s=arr[0]
,,,_s.findreplace(":" "/")
,,,_s+ F" {arr[1]}"
,,,dt.FromStr(_s)
,,,out dt.ToStr(4)
,,else
,,,out R
#ret
using System;
using System.Drawing.Imaging;
using System.Drawing;
using System.Text;
public class Example
{
,public static string StaticFunc(string s)
,{
;;;;;;;;// Set the path to your photo file.
,,var path = @s;
,,var image = new Bitmap(path);
;;;;;;;;// Get PropertyItems
,,var propItems = image.PropertyItems;
;;;;;;;// Remove encoding object
,,var encodings = new ASCIIEncoding();
,,string datetime = "";
;;;;;;;// Display
,,int count = 0;
,,foreach (var propItem in propItems)
,,{
,,,// The values below come from http://msdn.microsoft.com/en-us/library/xddt0dz7(v=vs.110).aspx
,,,if (propItem.Id.ToString("x").Equals("9003")) //ExifDTOriginal
,,,{
,,,,count = 1;
,,,,datetime = encodings.GetString(propItem.Value);
,,,}
,,}
,,if (count == 0)
,,{
,,,image.Dispose();
,,,return "No MetaData found";
,,}
,,else
,,{
,,,image.Dispose();
,,,return datetime;
,,}
,}
}


Messages In This Thread
RE: How to output date created and date modified? - by Kevin - 08-07-2019, 01:00 AM

Forum Jump:


Users browsing this thread: 5 Guest(s)