Click here to Skip to main content
15,893,564 members
Home / Discussions / C#
   

C#

 
QuestionWhat's the best method for calling a random function? Pin
tylocook11-Apr-09 13:43
tylocook11-Apr-09 13:43 
AnswerRe: What's the best method for calling a random function? Pin
PIEBALDconsult11-Apr-09 15:57
mvePIEBALDconsult11-Apr-09 15:57 
Questionhow to access sound card Pin
fitsum argaw11-Apr-09 13:18
fitsum argaw11-Apr-09 13:18 
AnswerRe: how to access sound card Pin
Henry Minute12-Apr-09 1:41
Henry Minute12-Apr-09 1:41 
Questionhow to use ctrl+v for pasting a image in the rich text box Pin
Jeweel11-Apr-09 10:30
Jeweel11-Apr-09 10:30 
AnswerRe: how to use ctrl+v for pasting an image in the rich text box Pin
Luc 64801111-Apr-09 11:16
Luc 64801111-Apr-09 11:16 
AnswerRe: i got the solution..... Pin
Jeweel11-Apr-09 11:56
Jeweel11-Apr-09 11:56 
Questionhow can I deny delete access to a folder/file using FileSystemWatcher Pin
leshu11-Apr-09 8:14
leshu11-Apr-09 8:14 
Hi,
I have a small application that monitors a specified windows folder and displays the activities performed on that folder.My aim is to track all the activities, like creation,renaming,updating files/subfolders under the specified folder, but never allows the user to delete a file or sub folder. I have used FileSystemWatcher(FSW) to track and handles the activities. But Iam not able to track the event that fires just before deletion, and thus not able to deny delete access. My code tracks the activites and informs me of the activities. Please find below the code i have written.I have specified only those part that tracks the folder.The tracking happens on a 'Button Start' click.

<pre>public partial class Frm_Monitor : Form
{

public FileSystemWatcher FileWatcher;
private void Btn_Start_Click(object sender, EventArgs e)
{

FileWatcher = new FileSystemWatcher();
string Path;
Path = txt_FolderPath.Text;//user can browse for the path

//Clear all the previous entry
Tmr_ForThread.Start(); //timer to start the thread



FileWatcher.Path = Path;
FileWatcher.NotifyFilter =
NotifyFilters.FileName | NotifyFilters.Attributes | NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.Security
| NotifyFilters.Size
| NotifyFilters.CreationTime;


FileWatcher.Changed += new FileSystemEventHandler (OnFileEvent);
FileWatcher.Created += new FileSystemEventHandler(OnFileEvent);
FileWatcher.Deleted += new FileSystemEventHandler(OnFileEvent);
FileWatcher.Renamed += new RenamedEventHandler(OnRenameEvent);
FileWatcher.IncludeSubdirectories = true;
FileWatcher.EnableRaisingEvents = true;

}

}</pre>

In the above code, under the 'OnFileEvent' and 'OnRenameEvent', I had written the code to get and pass the 'changetype' and 'fullpath' attribute of the eventhandler arguments to a sub routine. That sub routine uses MethodInvoker on a Listview.BeginInvoke, to display the 'changetype' and 'fullpath' onto a ListView control in the form Frm_Monitor.
Instead of using the FileWatcher.Deleted , what should i use so that I will know the moment the user clicks on deletion of a file/folder, rather than letting me know after the deletion?

Any help in the whole process/idea as soon as possible is much appreciated. Please let me know If i need to paste the whole program
AnswerRe: how can I deny delete access to a folder/file using FileSystemWatcher Pin
Colin Angus Mackay11-Apr-09 8:45
Colin Angus Mackay11-Apr-09 8:45 
JokeRe: how can I deny delete access to a folder/file using FileSystemWatcher Pin
Mycroft Holmes11-Apr-09 15:46
professionalMycroft Holmes11-Apr-09 15:46 
GeneralRe: how can I deny delete access to a folder/file using FileSystemWatcher Pin
leshu11-Apr-09 18:43
leshu11-Apr-09 18:43 
GeneralRe: how can I deny delete access to a folder/file using FileSystemWatcher Pin
Colin Angus Mackay11-Apr-09 23:47
Colin Angus Mackay11-Apr-09 23:47 
GeneralRe: how can I deny delete access to a folder/file using FileSystemWatcher Pin
leshu12-Apr-09 18:41
leshu12-Apr-09 18:41 
AnswerRe: how can I deny delete access to a folder/file using FileSystemWatcher Pin
Giorgi Dalakishvili12-Apr-09 1:25
mentorGiorgi Dalakishvili12-Apr-09 1:25 
QuestionTCP/IP Hates me and wants me to fail. Pin
jas0n2311-Apr-09 7:36
jas0n2311-Apr-09 7:36 
AnswerRe: TCP/IP Hates me and wants me to fail. Pin
Colin Angus Mackay11-Apr-09 7:41
Colin Angus Mackay11-Apr-09 7:41 
GeneralRe: TCP/IP Hates me and wants me to fail. Pin
jas0n2311-Apr-09 8:27
jas0n2311-Apr-09 8:27 
GeneralRe: TCP/IP Hates me and wants me to fail. Pin
Colin Angus Mackay11-Apr-09 8:33
Colin Angus Mackay11-Apr-09 8:33 
GeneralRe: TCP/IP Hates me and wants me to fail. Pin
jas0n2311-Apr-09 8:50
jas0n2311-Apr-09 8:50 
QuestionC# Multimedia controls [resolved] Pin
jano_rajmond11-Apr-09 7:02
jano_rajmond11-Apr-09 7:02 
RantRe: C# Multimedia controls [not an answer] Pin
Colin Angus Mackay11-Apr-09 7:45
Colin Angus Mackay11-Apr-09 7:45 
RantRe: C# Multimedia controls Pin
jano_rajmond11-Apr-09 7:47
jano_rajmond11-Apr-09 7:47 
GeneralRe: C# Multimedia controls Pin
Colin Angus Mackay11-Apr-09 7:56
Colin Angus Mackay11-Apr-09 7:56 
RantRe: C# Multimedia controls Pin
jano_rajmond11-Apr-09 8:04
jano_rajmond11-Apr-09 8:04 
GeneralRe: C# Multimedia controls [not an answer] Pin
Colin Angus Mackay11-Apr-09 8:31
Colin Angus Mackay11-Apr-09 8:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.