File.GetLastAccessTime 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
오버로드
| Name | Description |
|---|---|
| GetLastAccessTime(SafeFileHandle) |
지정된 파일 또는 디렉터리의 마지막 액세스 날짜 및 시간을 반환합니다. |
| GetLastAccessTime(String) |
지정된 파일 또는 디렉터리에 마지막으로 액세스한 날짜와 시간을 반환합니다. |
GetLastAccessTime(SafeFileHandle)
- Source:
- File.cs
- Source:
- File.cs
- Source:
- File.cs
- Source:
- File.cs
- Source:
- File.cs
지정된 파일 또는 디렉터리의 마지막 액세스 날짜 및 시간을 반환합니다.
public:
static DateTime GetLastAccessTime(Microsoft::Win32::SafeHandles::SafeFileHandle ^ fileHandle);
public static DateTime GetLastAccessTime(Microsoft.Win32.SafeHandles.SafeFileHandle fileHandle);
static member GetLastAccessTime : Microsoft.Win32.SafeHandles.SafeFileHandle -> DateTime
Public Shared Function GetLastAccessTime (fileHandle As SafeFileHandle) As DateTime
매개 변수
- fileHandle
- SafeFileHandle
SafeFileHandle 마지막 액세스 날짜 및 시간 정보를 가져올 파일 또는 디렉터리에 대한 A입니다.
반품
DateTime 지정된 파일 또는 디렉터리에 대한 마지막 액세스 날짜 및 시간으로 설정된 구조체입니다. 이 값은 현지 시간으로 표현됩니다.
예외
fileHandle은 null입니다.
호출자에게 필요한 권한이 없습니다.
적용 대상
GetLastAccessTime(String)
- Source:
- File.cs
- Source:
- File.cs
- Source:
- File.cs
- Source:
- File.cs
- Source:
- File.cs
지정된 파일 또는 디렉터리에 마지막으로 액세스한 날짜와 시간을 반환합니다.
public:
static DateTime GetLastAccessTime(System::String ^ path);
public static DateTime GetLastAccessTime(string path);
static member GetLastAccessTime : string -> DateTime
Public Shared Function GetLastAccessTime (path As String) As DateTime
매개 변수
- path
- String
액세스 날짜 및 시간 정보를 가져올 파일 또는 디렉터리입니다.
반품
DateTime 지정된 파일 또는 디렉터리에 마지막으로 액세스한 날짜 및 시간으로 설정된 구조체입니다. 이 값은 현지 시간으로 표현됩니다.
예외
호출자에게 필요한 권한이 없습니다.
.NET Framework 및 .NET Core 버전 2.1 이전: path 길이가 0인 문자열이거나, 공백만 포함하거나, 하나 이상의 잘못된 문자를 포함합니다. 메서드를 사용하여 잘못된 문자를 쿼리할 GetInvalidPathChars() 수 있습니다.
path은 null입니다.
지정된 경로, 파일 이름 또는 둘 다 시스템 정의 최대 길이를 초과합니다.
path 가 잘못된 형식입니다.
예제
다음 예제에서는 GetLastAccessTime를 보여줍니다.
using System;
using System.IO;
class Test
{
public static void Main()
{
try
{
string path = @"c:\Temp\MyTest.txt";
if (!File.Exists(path))
{
File.Create(path);
}
File.SetLastAccessTime(path, new DateTime(1985,5,4));
// Get the creation time of a well-known directory.
DateTime dt = File.GetLastAccessTime(path);
Console.WriteLine("The last access time for this file was {0}.", dt);
// Update the last access time.
File.SetLastAccessTime(path, DateTime.Now);
dt = File.GetLastAccessTime(path);
Console.WriteLine("The last access time for this file was {0}.", dt);
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
}
}
open System
open System.IO
let path = @"c:\Temp\MyTest.txt"
if File.Exists path |> not then
File.Create path |> ignore
File.SetLastAccessTime(path, DateTime(1985, 5, 4))
// Get the creation time of a well-known directory.
let dt = File.GetLastAccessTime path
printfn $"The last access time for this file was {dt}."
// Update the last access time.
File.SetLastAccessTime(path, DateTime.Now)
let dt2 = File.GetLastAccessTime path
printfn $"The last access time for this file was {dt2}."
Imports System.IO
Imports System.Text
Public Class Test
Public Shared Sub Main()
Try
Dim path As String = "c:\Temp\MyTest.txt"
If File.Exists(path) = False Then
File.Create(path)
End If
File.SetLastAccessTime(path, New DateTime(1985, 5, 4))
' Get the creation time of a well-known directory.
Dim dt As DateTime = File.GetLastAccessTime(path)
Console.WriteLine("The last access time for this file was {0}.", dt)
' Update the last access time.
File.SetLastAccessTime(path, DateTime.Now)
dt = File.GetLastAccessTime(path)
Console.WriteLine("The last access time for this file was {0}.", dt)
Catch e As Exception
Console.WriteLine("The process failed: {0}", e.ToString())
End Try
End Sub
End Class
설명
메모
이 메서드는 운영 체제에서 값을 지속적으로 업데이트하지 않을 수 있는 네이티브 함수를 사용하기 때문에 부정확한 값을 반환할 수 있습니다.
매개 변수에 path 설명된 파일이 없으면 이 메서드는 1601년 1월 1일 자정(C.E.) 12:00을 반환합니다. 현지 시간으로 조정된 UTC(협정 세계시)입니다.
path 매개 변수는 상대 또는 절대 경로 정보를 지정할 수 있습니다. 상대 경로 정보는 현재 작업 디렉터리를 기준으로 해석됩니다. 현재 작업 디렉터리를 가져오려면 다음을 참조하세요 GetCurrentDirectory.
일반적인 I/O 작업 목록은 일반적인 I/O 작업을 참조하세요.