×

C# Tutorial

Basics of .Net

C# Basics

C# Fundamentals

C# Operators

C# Loops

C# Type Conversions

C# Exception Handling

C# String Class

C# Arrays

C# List

C# Stack

C# Queue

C# Collections

C# Character Class

C# Class and Object

C# Namespaces

C# Delegates

C# Constructors

C# Inheritance

C# Operator Overloading

C# Structures

C# File Handling

C# Convert.ToInt32()

C# Int32 (int) Struct

C# DateTime Class

C# Uri Class

C# Database Connectivity

C# Windows

C# Other Topics

C# Q & A

C# Programs

C# Find O/P

C# | DateTime.ToFileTimeUtc() Method with Example

DateTime.ToFileTimeUtc() Method: Here, we are going to learn about the ToFileTimeUtc() method of DateTime class with example in C#. By IncludeHelp Last updated : August 27, 2023

C# DateTime.ToFileTimeUtc() Method

DateTime.ToFileTimeUtc() method is used to convert the current DateTime object into Windows file time.

Syntax

long DateTime.ToFileTimeUtc();

Parameter(s)

  • It does not accept any parameter.

Return value

The return type of this method is long – it returns a long integer value that represents the windows file time.

Example to demonstrate example of DateTime.ToFileTimeUtc() method

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //creating an object of DateTime class
            //and, initializing it with the current time 
            //using "Now"           
            DateTime dt = DateTime.Now;

            //converting to windows file time from current date time
            long time = dt.ToFileTimeUtc();

            //printing the current date & time
            Console.WriteLine("The current time is: " + dt.ToString());
            
            
            //printing time in windows file time 
            Console.WriteLine("Windows file time: " + time);

            //just to print a new line
            Console.WriteLine();
        }
    }
}

Output

RUN 1:
The current time is: 10/17/2019 1:17:21 PM
Windows file time: 132157918412997330

RUN 2:
The current time is: 10/17/2019 1:17:45 PM
Windows file time: 132157918652078310

If we run program multiple times, the output will be different.

Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.