File.GetLastWriteTime メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim path As String Dim returnValue As DateTime returnValue = File.GetLastWriteTime(path)
戻り値
指定したファイルまたはディレクトリに最後に書き込んだ日付と時刻に設定された DateTime 構造体。この値は現地時刻で表示されます。

例外の種類 | 条件 |
---|---|
UnauthorizedAccessException | |
ArgumentException | path が、長さが 0 の文字列であるか、空白しか含んでいないか、または InvalidPathChars で定義されている無効な文字を 1 つ以上含んでいます。 |
ArgumentNullException | path が null 参照 (Visual Basic では Nothing) です。 |
PathTooLongException | 指定したパス、ファイル名、またはその両方がシステム定義の最大長を超えています。たとえば、Windows ベースのプラットフォームの場合、パスの長さは 248 文字未満、ファイル名の長さは 260 文字未満である必要があります。 |
IOException | |
NotSupportedException |

path パラメータは、相対パス情報または絶対パス情報を指定することを許可されています。相対パス情報は、現在の作業ディレクトリに対して相対的に解釈されます。現在の作業ディレクトリを取得するには、GetCurrentDirectory のトピックを参照してください。
このメソッドの使用例については、「使用例」を参照してください。その他の一般的な I/O タスクまたは関連する I/O タスクの例を次の表に示します。

GetLastWriteTime を実行する例を次に示します。
Imports System 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) Else ' Take some action that will affect the write time. File.SetLastWriteTime(path, New DateTime(1985, 4, 3)) End If 'Get the creation time of a well-known directory. Dim dt As DateTime = File.GetLastWriteTime(path) Console.WriteLine("The last write time for this file was {0}.", dt) 'Update the last write time. File.SetLastWriteTime(path, DateTime.Now) dt = File.GetLastWriteTime(path) Console.WriteLine("The last write 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
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); } else { // Take an action that will affect the write time. File.SetLastWriteTime(path, new DateTime(1985 ,4,3)); } // Get the creation time of a well-known directory. DateTime dt = File.GetLastWriteTime(path); Console.WriteLine("The last write time for this file was {0}.", dt); // Update the last write time. File.SetLastWriteTime(path, DateTime.Now); dt = File.GetLastWriteTime(path); Console.WriteLine("The last write time for this file was {0}.", dt); } catch (Exception e) { Console.WriteLine("The process failed: {0}", e.ToString()); } } }
using namespace System; using namespace System::IO; int main() { try { String^ path = "c:\\Temp\\MyTest.txt"; if ( !File::Exists( path ) ) { File::Create( path ); } else { // Take an action that will affect the write time. File::SetLastWriteTime( path, DateTime(1985,4,3) ); } // Get the creation time of a well-known directory. DateTime dt = File::GetLastWriteTime( path ); Console::WriteLine( "The last write time for this file was {0}.", dt ); // Update the last write time. File::SetLastWriteTime( path, DateTime::Now ); dt = File::GetLastWriteTime( path ); Console::WriteLine( "The last write time for this file was {0}.", dt ); } catch ( Exception^ e ) { Console::WriteLine( "The process failed: {0}", e ); } }
import System.*; import System.IO.*; class Test { public static void main(String[] args) { try { String path = "c:\\Temp\\MyTest.txt"; if (!(File.Exists(path))) { File.Create(path); } else { // Take an action that will affect the write time. File.SetLastWriteTime(path, new DateTime(1985, 4, 3)); } // Get the creation time of a well-known directory. DateTime dt = File.GetLastWriteTime(path); Console.WriteLine("The last write time for this file was {0}.", dt); // Update the last write time. File.SetLastWriteTime(path, DateTime.get_Now()); dt = File.GetLastWriteTime(path); Console.WriteLine("The last write time for this file was {0}.", dt); } catch (System.Exception e) { Console.WriteLine("The process failed: {0}", e.ToString()); } } //main } //Test


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からFile.GetLastWriteTime メソッドを検索する場合は、下記のリンクをクリックしてください。

- File.GetLastWriteTime メソッドのページへのリンク