Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to output date created and date modified?
#13
 Emerson
I redid the function this version is a lot faster

Function GetDateTaken 
Code:
Copy      Help
out
int i
ARRAY(str) a
GetFilesInFolder a "$Desktop$\TEST\" ""
a.sort(8)
for i 0 a.len
,Dir d.dir(a[i])
,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)
,,out d.FileName
,,str R=CsFunc("" d.FullPath)
,,if(R !="No MetaData Found")
,,,DateTime dt
,,,dt.FromStr(R)
,,,out dt.ToStr(4)
,,else
,,,out R
#ret
using System;
using System.Drawing.Imaging;
using System.Drawing;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
public class Example
{
,private static Regex r = new Regex(":");
;;;;//retrieves the date taken without loading the whole image
,public static string GetDateTakenFromImage(string path)
,{
,,using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
,,using (Image myImage = Image.FromStream(fs, false, false))
,,{
,,,PropertyItem propItem = null;
,,,try
,,,{
,,,,propItem = myImage.GetPropertyItem(0x9003);
,,,}
,,,catch { }
,,,if (propItem != null)
,,,{
,,,,string dateTaken = r.Replace(Encoding.UTF8.GetString(propItem.Value), "-", 2);
,,,,return dateTaken;
,,,}
,,,else
,,,,return "No MetaData Found";
,,}
,}
}


Messages In This Thread
RE: How to output date created and date modified? - by Kevin - 08-08-2019, 06:57 PM

Forum Jump:


Users browsing this thread: 5 Guest(s)