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

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

Directory.SetLastWriteTime メソッド

ディレクトリ最後に書き込んだ日付と時刻設定します

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

Public Shared Sub SetLastWriteTime
 ( _
    path As String, _
    lastWriteTime As DateTime _
)
Dim path As String
Dim lastWriteTime As DateTime

Directory.SetLastWriteTime(path, lastWriteTime)
public static void SetLastWriteTime
 (
    string path,
    DateTime lastWriteTime
)
public:
static void SetLastWriteTime (
    String^ path, 
    DateTime lastWriteTime
)
public static void SetLastWriteTime
 (
    String path, 
    DateTime lastWriteTime
)
public static function SetLastWriteTime
 (
    path : String, 
    lastWriteTime : DateTime
)

パラメータ

path

ディレクトリパス

lastWriteTime

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

例外例外
例外種類条件

FileNotFoundException

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

ArgumentException

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

ArgumentNullException

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

PathTooLongException

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

UnauthorizedAccessException

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

PlatformNotSupportedException

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

ArgumentOutOfRangeException

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

解説解説
使用例使用例

SetLastWriteTime実行するコード例次に示します

Imports System
Imports System.IO

Public Class Test
    Public Shared Sub Main()
        Try
            Dim path As String
 = "c:\MyDir"
            If Directory.Exists(path) = False
 Then
                Directory.CreateDirectory(path)
            Else
                ' Take an action that will affect the write time.
                Directory.SetLastWriteTime(path, New DateTime(1985,
 4, 3))
            End If

            'Get the last write time of a well-known directory.
            Dim dt As DateTime = Directory.GetLastWriteTime(path)
            Console.WriteLine("The last write time for this directory
 was {0}", dt)

            'Update the last write time.
            Directory.SetLastWriteTime(path, DateTime.Now)
            dt = Directory.GetLastWriteTime(path)
            Console.WriteLine("The last write time for this directory
 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:\MyDir";
            if (!Directory.Exists(path)) 
            {
                Directory.CreateDirectory(path);
            } 
            else 
            {
                // Take an action that will affect the write time.
                Directory.SetLastWriteTime(path, new DateTime(1985
,4,3));
            }

            // Get the last write time of a well-known directory.
            DateTime dt = Directory.GetLastWriteTime(path);
            Console.WriteLine("The last write time for this
 directory was {0}", dt);
            
            //Update the last write time.
            Directory.SetLastWriteTime(path, DateTime.Now);
            dt = Directory.GetLastWriteTime(path);
            Console.WriteLine("The last write time for this
 directory was {0}", dt);
        } 
        catch (Exception e) 
        {
            Console.WriteLine("The process failed: {0}", e.ToString());
        }
    }
}
using namespace System;
using namespace System::IO;
void main()
{
   try
   {
      String^ path = "c:\\MyDir";
      if (  !Directory::Exists( path ) )
      {
         Directory::CreateDirectory( path );
      }
      else
      {
         
         // Take an action that will affect the write time.
         Directory::SetLastWriteTime( path, DateTime(1985,4,3) );
      }
      
      // Get the last write time of a well-known directory.
      DateTime dt = Directory::GetLastWriteTime( path );
      Console::WriteLine( "The last write time for this
 directory was {0}", dt );
      
      //Update the last write time.
      Directory::SetLastWriteTime( path, DateTime::Now );
      dt = Directory::GetLastWriteTime( path );
      Console::WriteLine( "The last write time for this
 directory 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:\\MyDir";

            if (!(Directory.Exists(path))) {
                Directory.CreateDirectory(path);
            }
            else {
                // Take an action that will affect the write time.
                Directory.SetLastWriteTime(path, new DateTime(1985,
 4, 3));
            }

            // Get the last write time of a well-known directory.
            DateTime dt = Directory.GetLastWriteTime(path);
            Console.WriteLine("The last write time for this
 directory was {0}", 
                dt);

            //Update the last write time.
            Directory.SetLastWriteTime(path, DateTime.get_Now());
            dt = Directory.GetLastWriteTime(path);
            Console.WriteLine("The last write time for this
 directory was {0}",
                dt);
        }
        catch (System.Exception e) {
            Console.WriteLine("The process failed: {0}", e.ToString());
        }
    } //main
} //Test
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS