如何使用C#确定哪个帐户修改了共享文件夹中的文件 [英] How to use C# to determine which account modified a file in shared folder
本文介绍了如何使用C#确定哪个帐户修改了共享文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图确定使用哪个用户帐户来使用C#修改共享文件夹中的文件.
I am trying to determine which user account is used to modify files in a shared folder using C#.
如果程序在具有共享文件夹的计算机上运行,就可以了.
It is ok if the program runs on the computer that has the shared folder.
推荐答案
您应创建一个包含FileSystemWatcher
的Windows Service
.从这里您可以确定哪个用户修改了引发OnChanged
事件的文件
You should create a Windows Service
that contains a FileSystemWatcher
. From here you may be able to determine which user modified the file that raised the OnChanged
event
watcher.Changed += new FileSystemEventHandler(OnChanged);
private static 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);
}
FileSystemWatcher
在目录或目录中的文件更改时,收听文件系统更改通知并引发事件.
Listens to the file system change notifications and raises events when a directory, or file in a directory, changes.
这篇关于如何使用C#确定哪个帐户修改了共享文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文