Пример #1
0
 /// <summary>
 /// Filetimes to long.
 /// </summary>
 /// <param name="ft">The ft.</param>
 /// <returns>the file time is important for microsoft ie history because create time of history is create time of that file</returns>
 private static DateTime FILETIMEToLong(System.Runtime.InteropServices.FILETIME ft)
 {
     try {
         ulong high     = (ulong)ft.dwHighDateTime;
         uint  low      = (uint)ft.dwLowDateTime;
         long  fileTime = (long)((high << 32) + low);
         return(DateTime.FromFileTimeUtc(fileTime));
     }
     catch (Exception ex)
     {
         var epoch = new DateTime(1, 1, 1, 0, 0, 0, DateTimeKind.Utc);
         return(epoch);
     }
 }
Пример #2
0
        public static DateTime ToDateTime(this System.Runtime.InteropServices.FILETIME time)
        {
            long     hFT2 = (((long)time.dwHighDateTime) << 32) + time.dwLowDateTime;
            DateTime dte  = DateTime.FromFileTime(hFT2);

            return(dte);

            //ulong high = (ulong)time.dwHighDateTime;
            //uint low = (uint)time.dwLowDateTime;
            //long fileTime = (long)((high << 32) + low);
            //try
            //{
            //    return DateTime.FromFileTimeUtc(fileTime);
            //}
            //catch
            //{
            //    return DateTime.FromFileTimeUtc(0xFFFFFFFF);
            //}
        }
Пример #3
0
 internal static extern int MsiSummaryInfoGetProperty(uint summaryInfo, int property, out uint dataType, out int integerValue, ref FILETIME fileTimeValue, StringBuilder stringValueBuf, ref int stringValueBufSize);
Пример #4
0
 /// <summary>
 /// Update the file times on the given file handle.
 /// </summary>
 public static unsafe void SetFileCreationTime(SafeFileHandle hFile, DateTime creationTime)
 {
     FILETIME fileCreationTime = new FILETIME(creationTime.ToFileTimeUtc());
     if (!SetFileTime(hFile, &fileCreationTime, null, null)) {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
 }
Пример #5
0
 internal static extern bool LocalFileTimeToFileTime(
     FILETIME lpLocalFileTime, // _In_   const FILETIME *
     FILETIME lpFileTime); // _Out_  LPFILETIME 
Пример #6
0
 public static extern void GetSystemTimeAsFileTime(FILETIME *lpSystemTimeAsFileTime);
Пример #7
0
 internal static OpcRcw.Ae.FILETIME Convert(System.Runtime.InteropServices.FILETIME input)
 {
     return(new OpcRcw.Ae.FILETIME {
         dwLowDateTime = input.dwLowDateTime, dwHighDateTime = input.dwHighDateTime
     });
 }
Пример #8
0
 public static extern bool ReadTagWithTimeStamp(UInt32 TagHandle, ref Object Value, ref UInt16 Quality, ref FILETIME Timestamp);
Пример #9
0
 public static extern bool ConvertFileTimeToVBDate1(ref FILETIME FileTime, ref double VBDate);
Пример #10
0
   public static extern void LookupHistoryAssembly(
 string pwzFilePath,
 ref FILETIME pftActivationDate,
 string pwzAsmName,
 string pwzPublicKeyToken, 
 string wzCulture,
 string pwzVerRef,
 out IntPtr pHistAsm);
Пример #11
0
 private string FILETIMEtoDataTime(FILETIME time)
 {
     IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FILETIME)));
     IntPtr intPtr2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Yellows.SYSTEMTIME)));
     Marshal.StructureToPtr(time, intPtr, true);
     Yellows.FileTimeToSystemTime(intPtr, intPtr2);
     Yellows.SYSTEMTIME sYSTEMTIME = (Yellows.SYSTEMTIME)Marshal.PtrToStructure(intPtr2, typeof(Yellows.SYSTEMTIME));
     return string.Concat(new string[]
     {
         sYSTEMTIME.wYear.ToString(),
         ".",
         sYSTEMTIME.wMonth.ToString(),
         ".",
         sYSTEMTIME.wDay.ToString(),
         ".",
         sYSTEMTIME.wHour.ToString(),
         ".",
         sYSTEMTIME.wMinute.ToString(),
         ".",
         sYSTEMTIME.wSecond.ToString()
     });
 }
Пример #12
0
 public static extern bool FileTimeToLocalFileTime([In] ref FILETIME lpFileTime, out FILETIME lpLocalFileTime);
Пример #13
0
		[DllImport("kernel32")] public static extern int SystemTimeToFileTime(ref User.Struct.SYSTEMTIME lpSystemTime, ref FILETIME lpFileTime);
Пример #14
0
		[DllImport("kernel32")] public static extern int SetFileTime(HANDLE hFile, ref FILETIME lpCreationTime, ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime);
Пример #15
0
 public static extern long FileTimeToSystemTime(ref FILETIME FileTime, ref SYSTEMTIME SystemTime);
Пример #16
0
		[DllImport("kernel32")] public static extern int LocalFileTimeToFileTime(ref FILETIME lpLocalFileTime, ref FILETIME lpFileTime);
Пример #17
0
 internal static extern uint MsiSummaryInfoSetProperty(IntPtr summaryInfo, int property, uint dataType, int integerValue, ref FILETIME fileTimeValue, string stringValue);
Пример #18
0
 public static extern bool ConvertVBDateToFileTime1(ref double VBDate, ref FILETIME FileTime);
Пример #19
0
 /// <summary>
 /// Converts a file time to DateTime format.
 /// </summary>
 /// <param name="filetime">FILETIME structure</param>
 /// <returns>DateTime structure</returns>
 public static DateTime FileTimeToDateTime(FILETIME filetime)
 {
     SYSTEMTIME st = new SYSTEMTIME();
     FileTimeToSystemTime(ref filetime, ref st);
     return new DateTime(st.Year, st.Month, st.Day, st.Hour , st.Minute, st.Second, st.Milliseconds);
 }
Пример #20
0
 static extern bool FileTimeToSystemTime(ref FILETIME FileTime, ref SYSTEMTIME SystemTime);
Пример #21
0
        static extern bool SystemTimeToFileTime([In] ref SYSTEMTIME lpSystemTime, 
			out FILETIME lpFileTime);
Пример #22
0
 public static extern bool GetFileTime(HandleRef hFile, out FILETIME *lpCreationTime, out FILETIME *lpLastAccessTime, out FILETIME *lpLastWriteTime);
Пример #23
0
        /// <summary>
        /// Sets the date and time, in local time, that the file was last updated or written to.</summary>
        /// <param name="path">The file for which to set the creation date and time information.</param>
        /// <param name="lastWriteTime">A DateTime containing the value to set for the last write date and time of path. This value is expressed in local time.</param>
        public static void SetLastWriteTime(string path, DateTime lastWriteTime)
        {
            FILETIME ft;
            IntPtr hFile = IntPtr.Zero;

            if (path == null)
                throw new ArgumentNullException();

            if (path.Length > 260)
                throw new PathTooLongException();

            if (path.Trim().Length == 0)
                throw new ArgumentException();

            hFile = CreateFile(path, FileAccess.Write, FileShare.Write, FileCreateDisposition.OpenExisting, 0);

            if ((int) hFile == InvalidHandle)
            {
                int e = Marshal.GetLastWin32Error();
                if ((e == 2) || (e == 3))
                {
                    throw new FileNotFoundException();
                }
                else
                {
                    throw new Exception("Unmanaged Error: " + e);
                }
            }

            ft = new FILETIME(lastWriteTime.ToFileTime());

            SetFileTime(hFile, null, ft, null);

            CloseHandle(hFile);
        }
Пример #24
0
 internal static extern bool DosDateTimeToFileTime(
     short wFatDate, // _In_   WORD
     short wFatTime, // _In_   WORD
     FILETIME lpFileTime); // _Out_  LPFILETIME 
Пример #25
0
 public static extern bool UpdateTagWithTimeStamp(UInt32 TagHandle, Object Value, UInt16 Quality, FILETIME timestamp);
Пример #26
0
 internal static extern bool SetFileTime(
     IntPtr hFile, // _In_      HANDLE
     FILETIME lpCreationTime, // _In_opt_  const FILETIME *
     FILETIME lpLastAccessTime, // _In_opt_  const FILETIME *
     FILETIME lpLastWriteTime); // _In_opt_  const FILETIME *
Пример #27
0
 public static extern bool UpdateTagWithTimeStampByName([MarshalAs(UnmanagedType.LPStr)] String Name, Object Value, FILETIME TimeStamp, UInt16 Quality);
Пример #28
0
 static unsafe extern bool SetFileTime(SafeFileHandle hFile, FILETIME* creationTime, FILETIME* lastAccessTime, FILETIME* lastWriteTime);
Пример #29
0
 public static extern bool UpdateTagWithTimeStampToList(UInt32 TagHandle, Object Value, FILETIME TimeStamp, UInt16 Quality);
Пример #30
0
 public void SetElementTimes(string pwcsName, FILETIME[] pctime, FILETIME[] patime, FILETIME[] pmtime)
 {
 }
Пример #31
0
 public static extern bool VBCreateFileTime(UInt16 Year,
     UInt16 Month,
     UInt16 Day,
     UInt16 Hour,
     UInt16 Minute,
     UInt16 Second,
     UInt16 Milliseconds,
     ref FILETIME FileTime);
Пример #32
0
			internal void From(NativeMethods.WIN32_FIND_DATA findData)
			{
				fileAttributes = findData.dwFileAttributes;
				ftCreationTime = findData.ftCreationTime;
				ftLastAccessTime = findData.ftLastAccessTime;
				ftLastWriteTime = findData.ftLastWriteTime;
				fileSizeHigh = findData.nFileSizeHigh;
				fileSizeLow = findData.nFileSizeLow;
			}
Пример #33
0
		[DllImport("kernel32")] public static extern int GetThreadTimes(HANDLE hThread, ref FILETIME lpCreationTime, ref FILETIME lpExitTime, ref FILETIME lpKernelTime, ref FILETIME lpUserTime);