File.SetCreationTime 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| SetCreationTime(SafeFileHandle, DateTime) |
設定檔案或目錄建立的日期與時間。 |
| SetCreationTime(String, DateTime) |
設定檔案建立的日期和時間。 |
SetCreationTime(SafeFileHandle, DateTime)
- 來源:
- File.cs
- 來源:
- File.cs
- 來源:
- File.cs
- 來源:
- File.cs
- 來源:
- File.cs
設定檔案或目錄建立的日期與時間。
public:
static void SetCreationTime(Microsoft::Win32::SafeHandles::SafeFileHandle ^ fileHandle, DateTime creationTime);
public static void SetCreationTime(Microsoft.Win32.SafeHandles.SafeFileHandle fileHandle, DateTime creationTime);
static member SetCreationTime : Microsoft.Win32.SafeHandles.SafeFileHandle * DateTime -> unit
Public Shared Sub SetCreationTime (fileHandle As SafeFileHandle, creationTime As DateTime)
參數
- fileHandle
- SafeFileHandle
A SafeFileHandle 傳送到設定建立日期與時間資訊的檔案或目錄。
例外狀況
fileHandle 是 null。
creationTime 指定一個超出此操作允許日期、時間或兩者範圍的值。
來電者沒有所需的權限。
執行作業時發生 I/O 錯誤。
適用於
SetCreationTime(String, DateTime)
- 來源:
- File.cs
- 來源:
- File.cs
- 來源:
- File.cs
- 來源:
- File.cs
- 來源:
- File.cs
設定檔案建立的日期和時間。
public:
static void SetCreationTime(System::String ^ path, DateTime creationTime);
public static void SetCreationTime(string path, DateTime creationTime);
static member SetCreationTime : string * DateTime -> unit
Public Shared Sub SetCreationTime (path As String, creationTime As DateTime)
參數
- path
- String
要設定建立日期和時間信息的檔案。
例外狀況
找不到指定的路徑。
.NET Framework 與 .NET Core 版本 2.1 以前: path 為零長度字串、僅含空白,或包含一個或多個無效字元。 你可以用這個 GetInvalidPathChars() 方法查詢無效字元。
path 是 null。
指定的路徑、檔名或兩者都超過系統定義的最大長度。
執行作業時發生 I/O 錯誤。
creationTime 指定一個超出此操作允許日期、時間或兩者範圍的值。
來電者沒有所需的權限。
path 格式無效。
備註
path參數允許指定相對或絕對路徑資訊。 相對路徑資訊會被解讀為相對於目前工作目錄的相對於。 欲取得目前的工作目錄,請參見 GetCurrentDirectory。
NTFS 格式的磁碟驅動器可能會在短時間內快取檔案元數據資訊,例如檔案建立時間。 因此,如果您要覆寫或取代現有的檔案,可能需要明確設定檔案的建立時間。
關於常見 I/O 任務的清單,請參見 Common I/O 任務。