Directory.SetLastWriteTimeUtc メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Directory.SetLastWriteTimeUtc メソッドの意味・解説 

Directory.SetLastWriteTimeUtc メソッド

ディレクトリ最後に書き込んだ日付と時刻世界協定時刻 (UTC) 形式設定します

名前空間: System.IO
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Sub SetLastWriteTimeUtc
 ( _
    path As String, _
    lastWriteTimeUtc As DateTime _
)
Dim path As String
Dim lastWriteTimeUtc As DateTime

Directory.SetLastWriteTimeUtc(path, lastWriteTimeUtc)
public static void SetLastWriteTimeUtc
 (
    string path,
    DateTime lastWriteTimeUtc
)
public:
static void SetLastWriteTimeUtc (
    String^ path, 
    DateTime lastWriteTimeUtc
)
public static void SetLastWriteTimeUtc
 (
    String path, 
    DateTime lastWriteTimeUtc
)
public static function SetLastWriteTimeUtc
 (
    path : String, 
    lastWriteTimeUtc : DateTime
)

パラメータ

path

ディレクトリパス

lastWriteTimeUtc

ディレクトリ最後に書き込んだ日付と時刻。この値は UTC 時刻表現されます。

例外例外
例外種類条件

FileNotFoundException

指定したパスが見つかりませんでした

ArgumentException

path が、長さが 0 の文字列であるか、空白しか含んでいないか、または InvalidPathChars で定義されている無効な文字1 つ以上含んでます。

ArgumentNullException

pathnull 参照 (Visual Basic では Nothing) です。

PathTooLongException

指定したパスファイル名、またはその両方システム定義の最大長を超えてます。たとえば、Windows ベースプラットフォーム場合パス長さ248 文字未満ファイル名長さ260 文字未満である必要があります

UnauthorizedAccessException

呼び出し元に必要なアクセス許可がありません。

PlatformNotSupportedException

現在のオペレーティング システムMicrosoft Windows NT 以降ではありません。

ArgumentOutOfRangeException

lastWriteTimeUtc は、この操作許可される日付または時刻範囲超える値を指定します

解説解説
使用例使用例

世界協定時刻 (UTC) を使用した場合出力違いを、次のコード例示します

' This sample shows the differences between dates from methods that
 use
'coordinated universal time (UTC) format and those that do not.
Imports System
Imports System.IO



Public Class DirectoryUTCTime
   
   Public Shared Sub Main()
      ' Set the directory.
      Dim n As String =
 "C:\test\newdir"
      'Create two variables to use to set the time.
      Dim dtime1 As New
 DateTime(2002, 1, 3)
      Dim dtime2 As New
 DateTime(1999, 1, 1)
      
      'Create the directory.
      Try
         Directory.CreateDirectory(n)
      Catch e As IOException
         Console.WriteLine(e)
      End Try
      
      'Set the creation and last access times to a variable DateTime
 value.
      Directory.SetCreationTime(n, dtime1)
      Directory.SetLastAccessTimeUtc(n, dtime1)
      
      ' Print to console the results.
      Console.WriteLine("Creation Date: {0}", Directory.GetCreationTime(n))
      Console.WriteLine("UTC creation Date: {0}",
 Directory.GetCreationTimeUtc(n))
      Console.WriteLine("Last write time: {0}", Directory.GetLastWriteTime(n))
      Console.WriteLine("UTC last write time: {0}",
 Directory.GetLastWriteTimeUtc(n))
      Console.WriteLine("Last access time: {0}", Directory.GetLastAccessTime(n))
      Console.WriteLine("UTC last access time: {0}",
 Directory.GetLastAccessTimeUtc(n))
      
      'Set the last write time to a different value.
      Directory.SetLastWriteTimeUtc(n, dtime2)
      Console.WriteLine("Changed last write time: {0}",
 Directory.GetLastWriteTimeUtc(n))
   End Sub 'Main
End Class 'DirectoryUTCTime

' Since this sample deals with dates and times, the output will vary
' depending on when you run the executable. Here is one example of the
 output:

' Creation Date: 1/3/2002 12:00:00 AM
' UTC creation Date: 1/3/2002 8:00:00 AM
' Last write time: 12/31/1998 4:00:00 PM
' UTC last write time: 1/1/1999 12:00:00 AM
' Last access time: 1/2/2002 4:00:00 PM
' UTC last access time: 1/3/2002 12:00:00 AM
' Changed last write time: 1/1/1999 12:00:00 AM
// This sample shows the differences between dates from methods that
 use
//coordinated universal time (UTC) format and those that do not.
using System;
using System.IO;

namespace IOSamples
{
  public class DirectoryUTCTime
  {
    public static void Main()
    {
    // Set the directory.
      string n = @"C:\test\newdir";
        //Create two variables to use to set the time.
      DateTime dtime1 = new DateTime(2002, 1, 3);
      DateTime dtime2 = new DateTime(1999, 1, 1);

    //Create the directory.
      try
      {
          Directory.CreateDirectory(n);
      }
      catch (IOException e)
      {
          Console.WriteLine(e);
      }

    //Set the creation and last access times to a variable DateTime
 value.
      Directory.SetCreationTime(n, dtime1);
      Directory.SetLastAccessTimeUtc(n, dtime1);

        // Print to console the results.
      Console.WriteLine("Creation Date: {0}", Directory.GetCreationTime(n));
      Console.WriteLine("UTC creation Date: {0}", Directory.GetCreationTimeUtc(n));
      Console.WriteLine("Last write time: {0}", Directory.GetLastWriteTime(n));
      Console.WriteLine("UTC last write time: {0}", Directory.GetLastWriteTimeUtc(n));
      Console.WriteLine("Last access time: {0}", Directory.GetLastAccessTime(n));
      Console.WriteLine("UTC last access time: {0}", Directory.GetLastAccessTimeUtc(n));

        //Set the last write time to a different value.
      Directory.SetLastWriteTimeUtc(n, dtime2);
      Console.WriteLine("Changed last write time: {0}", Directory.GetLastWriteTimeUtc(n));
    }
  }
}
// Obviously, since this sample deals with dates and times, the output
 will vary
// depending on when you run the executable. Here is one example of
 the output:
//Creation Date: 1/3/2002 12:00:00 AM
//UTC creation Date: 1/3/2002 8:00:00 AM
//Last write time: 12/31/1998 4:00:00 PM
//UTC last write time: 1/1/1999 12:00:00 AM
//Last access time: 1/2/2002 4:00:00 PM
//UTC last access time: 1/3/2002 12:00:00 AM
//Changed last write time: 1/1/1999 12:00:00 AM

// This sample shows the differences between dates from methods that
 use
//coordinated universal time (UTC) format and those that do not.
using namespace System;
using namespace System::IO;
int main()
{
   
   // Set the directory.
   String^ n = "C:\\test\\newdir";
   
   //Create two variables to use to set the time.
   DateTime dtime1 = DateTime(2002,1,3);
   DateTime dtime2 = DateTime(1999,1,1);
   
   //Create the directory.
   try
   {
      Directory::CreateDirectory( n );
   }
   catch ( IOException^ e ) 
   {
      Console::WriteLine( e );
   }

   
   //Set the creation and last access times to a variable DateTime value.
   Directory::SetCreationTime( n, dtime1 );
   Directory::SetLastAccessTimeUtc( n, dtime1 );
   
   // Print to console the results.
   Console::WriteLine( "Creation Date: {0}", Directory::GetCreationTime(
 n ) );
   Console::WriteLine( "UTC creation Date: {0}", Directory::GetCreationTimeUtc(
 n ) );
   Console::WriteLine( "Last write time: {0}", Directory::GetLastWriteTime(
 n ) );
   Console::WriteLine( "UTC last write time: {0}", Directory::GetLastWriteTimeUtc(
 n ) );
   Console::WriteLine( "Last access time: {0}", Directory::GetLastAccessTime(
 n ) );
   Console::WriteLine( "UTC last access time: {0}", Directory::GetLastAccessTimeUtc(
 n ) );
   
   //Set the last write time to a different value.
   Directory::SetLastWriteTimeUtc( n, dtime2 );
   Console::WriteLine( "Changed last write time: {0}", Directory::GetLastWriteTimeUtc(
 n ) );
}

// Obviously, since this sample deals with dates and times, the output
 will vary
// depending on when you run the executable. Here is one example of
 the output:
//Creation Date: 1/3/2002 12:00:00 AM
//UTC creation Date: 1/3/2002 8:00:00 AM
//Last write time: 12/31/1998 4:00:00 PM
//UTC last write time: 1/1/1999 12:00:00 AM
//Last access time: 1/2/2002 4:00:00 PM
//UTC last access time: 1/3/2002 12:00:00 AM
//Changed last write time: 1/1/1999 12:00:00 AM
// This sample shows the differences between dates from methods that
 use
// coordinated universal time (UTC) format and those that do not.
import System.*;
import System.IO.*;

public class DirectoryUTCTime
{
    public static void main(String[]
 args)
    {
        // Set the directory.
        String n = "C:\\test\\newdir";
        //Create two variables to use to set the time.
        DateTime dTime1 = new DateTime(2002, 1, 3);
        DateTime dTime2 = new DateTime(1999, 1, 1);
        //Create the directory.
        try {
            Directory.CreateDirectory(n);
        }
        catch (IOException e) {
            Console.WriteLine(e);
        }
        //Set the creation and last access times to a variable DateTime
 value.
        Directory.SetCreationTime(n, dTime1);
        Directory.SetLastAccessTimeUtc(n, dTime1);
        // Print to console the results.
        Console.WriteLine("Creation Date: {0}", Directory.GetCreationTime(n));
        Console.WriteLine("UTC creation Date: {0}",
            Directory.GetCreationTimeUtc(n));
        Console.WriteLine("Last write time: {0}",
            Directory.GetLastWriteTime(n));
        Console.WriteLine("UTC last write time: {0}",
            Directory.GetLastWriteTimeUtc(n));
        Console.WriteLine("Last access time: {0}", 
            Directory.GetLastAccessTime(n));
        Console.WriteLine("UTC last access time: {0}", 
            Directory.GetLastAccessTimeUtc(n));
        //Set the last write time to a different value.
        Directory.SetLastWriteTimeUtc(n, dTime2);
        Console.WriteLine("Changed last write time: {0}", 
            Directory.GetLastWriteTimeUtc(n));
    } //main
} //DirectoryUTCTime
// Obviously, since this sample deals with dates and times, the output
// will vary depending on when you run the executable. Here is one example
// of the output:
// Creation Date: 1/3/2002 12:00:00 AM
// UTC creation Date: 1/3/2002 8:00:00 AM
// Last write time: 12/31/1998 4:00:00 PM
// UTC last write time: 1/1/1999 12:00:00 AM
// Last access time: 1/2/2002 4:00:00 PM
// UTC last access time: 1/3/2002 12:00:00 AM
// Changed last write time: 1/1/1999 12:00:00 AM
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Directory.SetLastWriteTimeUtc メソッド」の関連用語

Directory.SetLastWriteTimeUtc メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Directory.SetLastWriteTimeUtc メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS