欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來(lái)到入門(mén)教程網(wǎng)!

C語(yǔ)言

當(dāng)前位置:主頁(yè) > 軟件編程 > C語(yǔ)言 >

c++文件監(jiān)控之FileSystemWatcher

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語(yǔ)言|點(diǎn)擊: 次

具體代碼如下:

#using <System.dll>
#include <iostream>

using namespace std;
using namespace System;
using namespace System::IO;
using namespace System::Security::Permissions;

public ref class Watcher
{
private:
  // Define the event handlers.
  static void OnChanged( Object^ /*source*/, FileSystemEventArgs^ e )
  {
   // Specify what is done when a file is changed, created, or deleted.
   Console::WriteLine( "File: {0} {1}", e->FullPath, e->ChangeType );
  }

  static void OnRenamed( Object^ /*source*/, RenamedEventArgs^ e )
  {
   // Specify what is done when a file is renamed.
   Console::WriteLine( "File: {0} renamed to {1}", e->OldFullPath, e->FullPath );
  }

public:
  [PermissionSet(SecurityAction::Demand, Name="FullTrust")]
  int static run()
  {
   //array<String^>^args = System::Environment::GetCommandLineArgs();
   //創(chuàng)建一個(gè)FileSystemWatcher并設(shè)置它的屬性.
   FileSystemWatcher^ fsWatcher = gcnew FileSystemWatcher( );
   fsWatcher->Path = "C:\\files";

   /* Watch for changes in LastAccess and LastWrite times, and
     the renaming of files or directories. */
   fsWatcher->NotifyFilter = static_cast<NotifyFilters>(//監(jiān)聽(tīng)文件的以下屬性 按需求添加 這里我添加了一些常用的
                NotifyFilters::LastAccess | //文件或文件夾上一次打開(kāi)的日期。 
                NotifyFilters::LastWrite | //上一次向文件或文件夾寫(xiě)入內(nèi)容的日期
                NotifyFilters::FileName | //文件名
                NotifyFilters::DirectoryName | //目錄名
                NotifyFilters::Size); //大小

   //監(jiān)聽(tīng)子目錄
   fsWatcher->IncludeSubdirectories = true;
   // Only watch text files.
   //fsWatcher->Filter = "*.txt";

   // Add event handlers.
   fsWatcher->Changed += gcnew FileSystemEventHandler( Watcher::OnChanged );
   fsWatcher->Created += gcnew FileSystemEventHandler( Watcher::OnChanged );
   fsWatcher->Deleted += gcnew FileSystemEventHandler( Watcher::OnChanged );
   fsWatcher->Renamed += gcnew RenamedEventHandler( Watcher::OnRenamed );

   // Begin watching.
   fsWatcher->EnableRaisingEvents = true;

   // Wait for the user to quit the program.
   Console::WriteLine( "Press \'q\' to quit the sample." );
   while ( Console::Read() != 'q' );

   return 0;
  }
};

int main() {
  Watcher::run();
}

過(guò)程 1.首先創(chuàng)建FileSystemWatcher 對(duì)象  用來(lái)設(shè)置一些屬性以及添加監(jiān)聽(tīng)事件

   2.設(shè)置監(jiān)聽(tīng)目錄

   3.設(shè)置監(jiān)聽(tīng)文件的屬性

   4.設(shè)置監(jiān)聽(tīng)子目錄

   5.添加監(jiān)聽(tīng)事件

   6.開(kāi)始監(jiān)聽(tīng)

上面的sample代碼可以在MSDN上找到,如果有不確定的地方,可以查看文檔

上一篇:C++中rapidjson組裝map和數(shù)組array的代碼示例

欄    目:C語(yǔ)言

下一篇:利用rapidjson實(shí)現(xiàn)解析嵌套的json的方法示例

本文標(biāo)題:c++文件監(jiān)控之FileSystemWatcher

本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/361.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有