酷问答logo

Linux世界中是否有与.Net FileSystemWatcher等效的文件?(和linux)

对于想了解Linux世界中是否有与.NetFileSystemWatcher等效的文件?的读者,本文将是一篇不可错过的文章,我们将详细介绍和linux,并且为您提供关于.netFileSystemWa

对于想了解Linux世界中是否有与.Net FileSystemWatcher等效的文件?的读者,本文将是一篇不可错过的文章,我们将详细介绍和linux,并且为您提供关于.net FileSystemWatcher不拾取移动的文件夹、.Net Windows服务和FileSystemWatcher问题、.NetCore-网络驱动器上的FileSystemWatcher,不安全代码Win32 API崩溃、14.QT-QFile文件,QBuffer缓冲区,QDir目录,QFileSystemWatcher文件系统监视的有价值信息。

本文目录一览:

Linux世界中是否有与.Net FileSystemWatcher等效的文件?(和linux)

Linux世界中是否有与.Net FileSystemWatcher等效的文件?(和linux)

我发现.Net FileSystemWatcher类非常适合编写实用程序,当文件显示在其监视的文件夹中时,这些实用程序会自动启用。*
nix世界中是否有与此功能等效的功能,可以让我监视文件夹(可能还有其所有子目录)?

编辑: 最好是不需要内核补丁的东西。

答案1

小编典典

那就是Gamin文件变更监视器或Inotify。

编辑:Mono确实具有Gamin绑定-实际上,其FileSystemWatcher的实现使用Gamin。https://www.mono-
project.com/docs/faq/technical/#what-are-the-issues-with-
filesystemwatcher。

FileSystemWatcher有什么问题?

FileSystemWatcher的Mono实现具有许多后端,其中最理想的是后端,而依赖关系较少的是inotify-backend(在Mono
1.1.17和更高版本中可用)。

通过此后端,内核为Mono提供了文件系统上文件更改的更新,但它需要启用inotify的内核,只有较新的Linux发行版才能提供该内核。

在较旧的Linux系统中,您必须已安装FAM或Gamin(它将与任何一种一起使用)。您可能需要安装-devel数据包。

对于* BSD系列,有一个基于Kqueue的实现,在运行时检测到该实现。

如果以上方法均无效,Mono将退回轮询目录以进行更改,这远非最佳选择。

.net FileSystemWatcher不拾取移动的文件夹

.net FileSystemWatcher不拾取移动的文件夹

我发现了很多有关移动文件 (我没有问题)的讨论,但没有任何具体的移动文件夹 (因此这篇文章)。

我有一个FileSystemWatcher实例化如下:

var fileWatcher = new FileSystemWatcher("C:\mypath"); fileWatcher.IncludeSubdirectories = true; fileWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.CreationTime | NotifyFilters.Size; fileWatcher.Changed += OnChanged; fileWatcher.Created += OnChanged; fileWatcher.Deleted += OnDeleted; fileWatcher.Renamed += OnRenamed; fileWatcher.Error += WatcheronError; fileWatcher.EnableRaisingEvents = true;

无论我如何处理文件,我都会按预期方式获取事件,但是如果文件夹(即使是带有文件的文件夹) 拖动 (移动)到观察的文件夹中,则根本没有任何事件发生。

我在Windows 10上运行(不知道如果其他版本的胜利performance相同的方式)。

Winforms Webbrowser告诉什么时候完成刷新

作为另一个用户启动Windows进程,而不直接知道密码

以编程方式获取Windows体验索引值

监视文件/目录访问在C#

哪个DVCS适合一个人的.NET商店?

有谁知道如何得到一个文件夹移动通知?

如何通过键查找/检查字典值

Windows服务来检测networking更改事件

是否有可能从另一个进程捕获“找不到文件”,然后将文件返回到该进程?

TimeZoneInfo和CultureInfo的System.DateTime和Caching

与.NET集成的Ruby on Rails的状态是什么?

您明确地排除了目录更改,因为NotifyFilters.DirectoryName中不包括NotifyFilter 。

这是一个链接到文档,但它只是正确的暗示:-)我证实了它只是使用你的代码没有,然后与额外的标志。

奇怪的是,这对我有用:

void Main() { FileSystemWatcher fsw = new FileSystemWatcher(@"c:Temp"); fsw.IncludeSubdirectories = true; fsw.Changed += new FileSystemEventHandler(OnChanged); fsw.EnableRaisingEvents = true; while (true) { } } void OnChanged(object source,FileSystemEventArgs e) { // Specify what is done when a file is changed,created,or deleted. Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType); }

.Net Windows服务和FileSystemWatcher问题

.Net Windows服务和FileSystemWatcher问题

我已经搜遍了很多四米,并没有find任何解决scheme,我希望有人能够帮助我在这个论坛。

我有.net Windows服务与两个FSW监视networking上的文件夹。

文件夹结构 NetworkDrive NewFolder InputDirectory NetworkDrive NewFolder WorkingDirectory

当我将多个文件复制到 NetworkDrive NewFolder InputDirectory目录时,可以说file1,file2,file3和file4,然后只处理file1,file2和file3,并且将一个文件

将消息发送到Windows GUI线程

处理数据库模式中的更改

Linux上的C#:如何枚举本地networking上的计算机?

什么时候由.NET进程分配的内存被释放回Windows

防止对象被分页(VirtualLock相当于)

以下是服务类和filesystemwatcher类的代码

服务类

using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.ServiceProcess; using System.Security.Permissions; namespace Service1 { public partial class Service1 : ServiceBase { public FaxInbound() { InitializeComponent(); this.ServiceName = "Service1"; } protected override void OnStart(string[] args) { onServiceStartProcess(); } protected override void OnStop() { try { workingSysTimer.Enabled = false; inboundSysTimer.Enabled = false; workingSysTimer.Stop(); inboundSysTimer.Stop(); } catch (ApplicationException ex) { throw new ProblemException(ex.Message,ex.InnerException); } } [PermissionSet(SecurityAction.Demand,Name = "FullTrust")] private void inboundSysTimer_Elapsed(object sender,System.Timers.ElapsedEventArgs e) { try { WatchFileSystem.Run(inboundFSW,inputDirectory,directoryWatchfilter); } catch (ApplicationException ex) { throw new ProblemException(ex.Message,ex.InnerException); } finally { inboundSysTimer.Enabled = true; inboundSysTimer.Start(); } } [PermissionSet(SecurityAction.Demand,Name = "FullTrust")] private void workingSysTimer_Elapsed(object sender,System.Timers.ElapsedEventArgs e) { try { WatchFileSystem.Run(workingFSW,workingDirectory,ex.InnerException); } finally { workingSysTimer.Enabled = true; workingSysTimer.Start(); } } internal void onServiceStartProcess() { try { setConfig(); inboundSysTimer.Enabled = true; workingSysTimer.Enabled = true; inboundSysTimer.Start(); workingSysTimer.Start(); } catch (ApplicationException ex) { throw new ProblemException(ex.Message,ex.InnerException); } } } }

FileSystemwatcher类

using System; using System.IO; using System.Text; using System.Diagnostics; using System.Collections.Generic; using System.Security.Permissions; namespace Service1 { [Serializable()] internal class WatchFileSystem { [PermissionSet(SecurityAction.Demand,Name="FullTrust")] internal static void Run(System.IO.FileSystemWatcher watcher,string directoryPath = "",string fileFilter = "*.*") { try { string args = directoryPath; if (args.Length < 3) { return; } watcher.Path = args; watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.DirectoryName | NotifyFilters.FileName; watcher.Filter = fileFilter; watcher.InternalBufferSize = 64; if (watcher.Path == inputDirectory) { watcher.Changed += new FileSystemEventHandler(OnInputDirectoryChanged); watcher.Created += new FileSystemEventHandler(OnInputDirectoryChanged); watcher.Error += new ErrorEventHandler(OnInputDirectoryError); } if (watcher.Path == workingDirectory) { watcher.Changed += new FileSystemEventHandler(OnWorkingDirectoryChanged); watcher.Created += new FileSystemEventHandler(OnWorkingDirectoryChanged); watcher.Error += new ErrorEventHandler(OnWorkingDirectoryError); } watcher.EnableRaisingEvents = true; } catch (ApplicationException ex) { throw new ProblemException(ex.Message,Name = "FullTrust")] internal static void OnInputDirectoryChanged(object source,FileSystemEventArgs e) { try { System.IO.FileStream file = null; try { if (System.IO.File.Exists(e.FullPath) == true) { file = File.Open(e.FullPath,FileMode.Open,FileAccess.Read,FileShare.Read); } } catch (IOException) { System.Threading.Thread.Yield(); System.Threading.Thread.Sleep(100); // hack for timing issues return; } finally { if (file != null) file.dispose(); } if (e.ChangeType == WatcherChangeTypes.Created) { System.IO.FileInfo infoFile = new System.IO.FileInfo(e.FullPath); if (infoFile.Exists == true) { infoFile = null; try { if (file != null) { file.Close(); file.dispose(); } if (System.IO.File.Exists(e.FullPath) == true) { if (System.IO.File.Exists(System.IO.Path.Combine(workingDirectory,e.Name)) == false) { System.IO.File.Move(e.FullPath,System.IO.Path.Combine(workingDirectory,e.Name)); } } } catch (IOException) { System.Threading.Thread.Yield(); System.Threading.Thread.Sleep(100); // hack for timing issues return; } } } } catch (ApplicationException ex) { throw new ProblemException(ex.Message,Name = "FullTrust")] private static void OnInputDirectoryError(object source,ErrorEventArgs e) { System.IO.FileSystemWatcher inboundFSW = new System.IO.FileSystemWatcher(); inboundFSW.EnableRaisingEvents = true; inboundFSW.IncludeSubdirectories = false; while (!inboundFSW.EnableRaisingEvents) { try { WatchFileSystem.Run(inboundFSW,directoryWatchfilter); } catch { System.Threading.Thread.Sleep(5000); } } } [PermissionSet(SecurityAction.Demand,Name = "FullTrust")] internal static void OnWorkingDirectoryChanged(object source,FileShare.Read); } } catch (IOException) { System.Threading.Thread.Yield(); System.Threading.Thread.Sleep(100); // hack for timing issues return; } finally { if (file != null) file.dispose(); } if (e.ChangeType == WatcherChangeTypes.Created) { System.IO.FileInfo infoFile = new System.IO.FileInfo(e.FullPath); if (infoFile.Exists == true) { infoFile = null; try { if (file != null) { file.Close(); file.dispose(); } if (System.IO.File.Exists(e.FullPath) == true) { generateFiles(System.IO.Path.Combine(workingDirectory,e.Name)); } } catch (IOException) { System.Threading.Thread.Yield(); System.Threading.Thread.Sleep(100); // hack for timing issues return; } } } } catch (ApplicationException ex) { throw new ProblemException(ex.Message,Name = "FullTrust")] private static void OnWorkingDirectoryError(object source,ErrorEventArgs e) { System.IO.FileSystemWatcher workingFSW = new System.IO.FileSystemWatcher(); workingFSW.EnableRaisingEvents = true; workingFSW.IncludeSubdirectories = false; while (!workingFSW.EnableRaisingEvents) { try { WatchFileSystem.Run(workingFSW,directoryWatchfilter); } catch { System.Threading.Thread.Sleep(5000); } } } } }

任何帮助将不胜感激。

Win C#:以pipe理员身份运行应用程序,无需UAC提示

我可以使用没有.NET库的Windows身份validation使用WCF REST服务吗?

.NET本地Windows商店版本

SSL支持Rabbit + .Net + Windows

.net3.5应用程序与.net框架4

如果您还没有找到答案,请参阅: FileSystemWatcher问题

您是否考虑过使用投票系统? 您可以使用创建一个新线程,检查新文件并复制/移动它们,然后使用Thread.Sleep()使线程在您选择的特定时间间隔内休眠。 并通过这个过程循环。

.NetCore-网络驱动器上的FileSystemWatcher,不安全代码Win32 API崩溃

.NetCore-网络驱动器上的FileSystemWatcher,不安全代码Win32 API崩溃

快速更新,因为我仍在解决它。

我创建了一个MS支持问题。 经过多次尝试,我们才成功复制了它。我们必须“玩”网络并模拟一些“干扰”。 似乎FileSystemWatcher事件未按应有的方式发送(它是通过TCP协议,SMB方式发送的)。 我们的团队仍在努力寻找可能的方法。

MS同意,无论是否存在真正的网络问题,这都不会以一些不安全的代码使FileSystemWatcher崩溃。 因此,他们只是做了PR来增加一些安全性。

我仍在关注PR,但应该在.Net 5中进行修复,并在.Net Core 3.1(.9)中向后移植。

感谢您的帮助。

,

此问题已在master (6.0)中修复,并反向移植到5.0和3.1。

14.QT-QFile文件,QBuffer缓冲区,QDir目录,QFileSystemWatcher文件系统监视

14.QT-QFile文件,QBuffer缓冲区,QDir目录,QFileSystemWatcher文件系统监视

QFile

Qt中所有与IO相关的类都继承于QIODevice,继承图如下所示:

其中QFile类便是用于文件操作的类

在QT中,将文件当做一种特殊的外部设备对待(比如:串口,usb等就是外部设备)

 

QT中,IO操作相关的函数接口,常用以下几种

打开设备

bool open(OpenMode mode);                          //打开文件成功返回true,否则返回false
                       // mode有:
                // QIODevice::ReadOnly 、QIODevice::WriteOnly、QIODevice::ReadWrite
              // QIODevice::Append :写入的数据将会写在文件末尾
             // QIODevice::Truncate :打开文件后,之前的内容将会消失(默认Truncate是打开的)
            //QIODevice::Text:以文本方式写入(若写"\n",在win平台上则自动被翻译为"\r\n"),否则以数据方式写入(写入的是字节)

读取数据

QByteArray read(qint64 maxSize)                          //从设备读取最多maxSize字节的数据 , QByteArray 类可以默认转换为QString类
QByteArray readAll();                                    //读出所有数据
qint64  readData ( char * data, qint64 maxSize );        //读出最多maxSize字节的数据,送到char * data里, 并返回成功写入的字节数,失败则返回-1
QByteArray QIODevice::readLine ( qint64 maxSize = 0 );   //读出一行数据

写入数据

qint64 write(const QByteArray & byteArray)   //将byteArray写入设备,返回成功写入的字节数,失败则返回-1
qint64  writeData ( const char * data, qint64 len );
                                   //从char * data里写入最多len字节的数据到设备, 并返回成功写入的字节数,失败则返回-1

关闭设备

void close();
  • IO操作的本质是读写连续的存储空间数据

 

QT中,存取IO设备分为两种

-顺序存取设备(比如:串口)

只能从头开始顺序的读写数据,不能指定数据的读写位置

-随机存取设备(比如:文件)

可以随机定位到任意位置,进行数据读写,通过seek()函数实现

  

QFile文本文件操作示例

在Qt中,一个QFile对象便对应着一个文件

QFile file file("C:/Users/Administrator/Desktop/test.txt");   //创建文件对象

         /*写数据*/
    if( file.open(QIODevice::WriteOnly | QIODevice::Text) )
    {
        file.write("D.T.Software\n");
        file.write("Delphi Tang\n");
        file.close();
    }
        /*读数据*/
    if( file.open(QIODevice::ReadOnly | QIODevice::Text) )
    {
        QByteArray ba = file.readLine();
        QString s(ba);                //将字节数组转换为字符串
        qDebug() << s;  
        file.close();
    }

 

QFileInfo类(获取文件属性信息)

示例:

QFile  file("C:/Users/Administrator/Desktop/test.txt");
    QFileInfo info(file);  

    qDebug() << info.exists();            //判断文件是否存在
    qDebug() << info.isFile();            //判断这个路径是文件,还是文件夹
    qDebug() << info.isReadable();        //该文件是否可读
    qDebug() << info.isWritable();        //该文件是否可写
    qDebug() << info.created();           //返回创建该文件的时间
    qDebug() << info.lastRead();          //返回最后访问文件的时间
    qDebug() << info.lastModified();      //返回最后修改文件的时间
    qDebug() << info.absolutePath();      //返回该文件的目录绝对路径
    qDebug() << info.fileName();          //返回该文件名称
    qDebug() << info.suffix();            //返回该文件后缀
    qDebug() << info.size();              //返回文件大小
    qDebug() << info.absoluteFilePath();  //返回该绝对路径

打印:

true
true
true
true
QDateTime("周三 五月 2 09:01:04 2018") QDateTime("周三 五月 2 09:01:04 2018") QDateTime("周三 五月 2 09:02:33 2018") "C:/Users/Administrator/Desktop" "test.txt" "txt" 27 "C:/Users/Administrator/Desktop/test.txt"

 

QFile数据文件操作示例:

由于write和read函数只能支持char参数,如果填入数值型QSTring型时,则需要转换:

QString  str="哈哈达";
     QFile file("C:/Users/Administrator/Desktop/test.hex");

         /*写数据*/
    if( file.open( QIODevice::WriteOnly ) )
    {
        double i=3.1412;
        file.write(str.toStdString().c_str());          //QString->string->char
        file.write(reinterpret_cast<char *>(&i),sizeof(i));   //写入8字节数据(数值)
        file.close();
    }

         /*读数据*/
    if( file.open(QIODevice::ReadOnly) )
    {
        QString s  = file.read(str.toStdString().length());
        qDebug() << s;

        double value;
        file.read(reinterpret_cast<char *>(&value),sizeof(value));  //读出double
        qDebug() << value;

        file.close();
    }

这样转换会显得非常麻烦,所以QT提供了辅助类来简化文本文件/数据文件的读写

 

QTextStream、QDataStream辅助类

QTextStream

将写入的数据全部转换为可读文本(适用于文本文件)

QDataStream

将写入的数据根据类型转换为二进制数据(适用于数据文件)

 

注意

QDataStream在不同版本中,数据格式可能不同,所以数据文件如果要在不同版本QT程序间传递,还需要考虑版本问题:

void setVersion(int v);    //设置读写版本号,比如4.7版本,则填入: QDataStream::Qt_4_7
int version();             //获取读写版本号

 

QTextStream使用示例

QFile file("C:/Users/Administrator/Desktop/test.txt");
        
/*写数据*/ if( file.open( QIODevice::WriteOnly| QIODevice::Text ) ) { QTextStream out(&file); //定义out对象,通过<<操作符向设备输出数据 out << QString("D.T.Software ")<<endl ; //将QString自动转为字符 out << QString("哈哈达") << endl; out << 5 << ''*'' << 6 << ''='' << 5 * 6 << endl; //将数值自动转为字符 file.close(); } /*读数据*/ if( file.open(QIODevice::ReadOnly| QIODevice::Text) ) { QTextStream in(&file); //定义in对象,通过>>操作符从设备读数据 while( !in.atEnd() ) { QString str; in>>str; qDebug()<<str; //打印3次 } file.close(); }

注意: endl其实只是加了\n,由于win平台的换行符是\r\n,所以需要加上QIODevice::Text,QT便会自动将\n转为\r\n.

 

QDataStream使用示例

QFile file("C:/Users/Administrator/Desktop/test.txt");

    if( file.open(QIODevice::WriteOnly) )
    {
        QDataStream out(&file);
        out.setVersion(QDataStream::Qt_4_7);                            //设置版本

        out << QString("D.T.Software");
        out << QString("Result: ");
        out << 3.14;
        file.close();
    }

    if( file.open(QIODevice::ReadOnly) )
    {
        QDataStream in(&file);
        QString dt = "";
        QString result = "";
        double value = 0;       
        in.setVersion(QDataStream::Qt_4_7);                       ////设置版本

        in >> dt;
        in >> result;
        in >> value;

        qDebug() << dt;
        qDebug() << result;
        qDebug() << value;

        file.close();
    }

 

QBuffer缓冲区

缓冲区的本质为一段连续的存储空间

  • 缓存区分为内部和外部,外部设备便表示外部缓冲区,而 QBuffer类则表示计算机的内部缓冲区
  • 在Qt中可以将缓冲区看作一种特殊的IO设备
  • QTextStream,QDataStream文件流辅助类也可以直接用于操作缓冲区

QBuffer缓冲区的使用场合

  • 通过进程间共享缓冲区,实现线程间不同类型的数据传递
  • 可以缓冲外部设备的读写数据,比如串口数据
  • 当数据读取速度小于写入速度时

QBuffer使用方法:

     QByteArray array;
     QBuffer buffer(&array);

     if(buffer.open(QIODevice::WriteOnly))
     {
         QDataStream out(&buffer);

         out << QString("3.1234");
         out << QString("scorpio");
         out << QString("1234");
         out << 1.34;

         buffer.close();
     }

     if(buffer.open(QIODevice::ReadOnly))
     {
         QDataStream in(&buffer);
         QString name;
         QString a;
         QString b;
         double num;

         in >> a;
         in >> name;
         in >> b;
         in >> num;

         qDebug() << name;
         qDebug() << a;
         qDebug() << b;
         qDebug() <<num;

         buffer.close();
     }

 

QDir目录

 QT中提供了目录操作类QDir,QDir功能如下:

  • 目录分隔符统一使用’/’
  • 能够对目录进行任意操作(创建、删除、重命名)
  • 能够获取指定目录中的所有条目(文件和文件夹)
  • 能够使用过滤字符串获取指定条目
  • 能够获取系统中的所有根目录

QDir使用方法如下:

QDir dir;

QString path = ("C:/Users/Administrator/Desktop/QDir");

if(!dir.exists(path))
{
  dir.mkdir(path);
}

else
{
  dir.cd(path);
  QStringList filters;                                  //字符串列表,用来筛选文件条目
  filters << "*.bmp" << "*.png";
  QStringList list = dir.entryList(filters,QDir::NoDotAndDotDot|QDir::AllEntries);
     // QDir::NoDotAndDotDot:不要出现.和..两个条目, QDir::AllEntries:所有(文件,目录等) 

  for(int i = 0; i < list.count(); i++)
  {
     qDebug() << list[i];
  }
}

 

来个示例,写个函数用来读取当前目录/或者文件的大小:

int Calculate_Size(QString PATH)
{
    int size=0;

    QFileInfo file(PATH);
    if(file.isFile())
    {
       return file.size();
    }

    else if(file.isDir())
    {
      QDir dir(PATH);
      QFileInfoList files = dir.entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries);
      qDebug()<<files.length();
      for(int i=0;i<files.length();i++)
      {
          qDebug()<<files[i].absoluteFilePath();
          size+=Calculate_Size(files[i].absoluteFilePath());    //递归地查找
      }
    }

    return size;
}

 

QFileSystemWatcher文件系统监视

用来监控目录或文件的状态变化

  • 能够同时对多个目录/文件进行监控
  • 当目录或文件发生改变时,将会触发信号
  • 可以通过信号与槽的机制捕捉信号,并做出响应

QFileSystemWatcher信号函数如下所示:

void directoryChanged ( const QString & path );
//当指定的目录被修改(例如该目录里一个文件被添加、修改或删除或从磁盘删除时),这个信号就会发出。

void ileChanged ( const QString & path );
//当指定的文件被修改、重命名或从磁盘删除时,就会发出这个信号

 

示例

QFsWatcher.h:

#ifndef QFSWATCHER_H
#define QFSWATCHER_H
#include <QObject> #include <QFileSystemWatcher> #include <QDebug> class QFsWatcher : public QObject { Q_OBJECT private : QFileSystemWatcher fs; private slots: void Dir_status( const QString & path ); void File_status( const QString & path ); public: explicit QFsWatcher(QObject *parent = 0); void addPath(const QString & path); }; #endif // QFSWATCHER_H

QFsWatcher.cpp:

#include "QFsWatcher.h"

QFsWatcher::QFsWatcher(QObject *parent) :
    QObject(parent)
{
    connect(&fs,SIGNAL(directoryChanged(const QString&)),this,SLOT(Dir_status(const QString&)) );
    connect(&fs,SIGNAL(fileChanged(const QString&)),this,SLOT(File_status(const QString&)) );
}

void QFsWatcher::Dir_status( const QString & path )
{
    qDebug()<<path<<": is Changed!";
}

void QFsWatcher::File_status( const QString & path )
{
    qDebug()<<path<<": is Changed!";
}

void QFsWatcher::addPath(const QString & path)
{
    fs.addPath(path);
}

main.cpp:

#include <QtCore/QCoreApplication>
#include "QFsWatcher.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QFsWatcher    watcher;

    watcher.addPath("C:/Users/Administrator/Desktop/QDir");      //监视QDir目录
    watcher.addPath("C:/Users/Administrator/Desktop/text.txt");  //监视text.txt文件

    return a.exec();
}

效果:

 

关于Linux世界中是否有与.Net FileSystemWatcher等效的文件?和linux的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于.net FileSystemWatcher不拾取移动的文件夹、.Net Windows服务和FileSystemWatcher问题、.NetCore-网络驱动器上的FileSystemWatcher,不安全代码Win32 API崩溃、14.QT-QFile文件,QBuffer缓冲区,QDir目录,QFileSystemWatcher文件系统监视等相关知识的信息别忘了在本站进行查找喔。

本文标签: