TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
TD SWE
NA
321
7.1k
How can I obtain the username when using a FileSystemWatcher
May 6 2014 4:50 AM
I am using a FileSystemWatcher to monitor a share folder on network. Three PC will share this folder and watch who accessing what.
I could read user name by using GetAccessControl function for 'Create function'
<pre lang="c#">protected void mywatcher_created(object sender,FileSystemEventArgs e)
{
string user_name = System.IO.File.GetAccessControl(e.FullPath).GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();
DateTime current = DateTime.Now;
lstCreate.Items.Add(e.FullPath.ToString());
lstCreate.Items[cCount].SubItems.Add(current.ToShortDateString());
lstCreate.Items[cCount].SubItems.Add(current.ToShortTimeString());
lstCreate.Items[cCount].SubItems.Add(user_name.ToString());
cCount += 1;
}
If I want to read user name for deleted , renamed or changed file , and GetAssessControl Function couldn't be used for those. I got error of 'filepath couln't find'.
So how can I read the user name of share folder.
I wrote deleted file by this function ,
protected void mywatcher_deleted(object sender, FileSystemEventArgs e)
{
string user_name = System.IO.File.GetAccessControl(e.FullPath).GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();
CheckForIllegalCrossThreadCalls = false;
DateTime current = DateTime.Now;
lstDelete.Items.Add(e.FullPath.ToString());
lstDelete.Items[dCount].SubItems.Add(current.ToShortDateString());
lstDelete.Items[dCount].SubItems.Add(current.ToShortTimeString());
lstDelete.Items[dCount].SubItems.Add(user_name.ToString());
dCount += 1;
}
Reply
Answers (
0
)
custom date in the excel
How to display dynamic data from db without using data ctrls