Anonymous

Anonymous

  • NA
  • 1
  • 1.3k

FileWatcher

Jun 6 2013 6:11 AM
I have made a FileWatcher but my FileWatcher isn't working as planned and i am stuck. I want to have a filewatcher that will work with 2 maps. The code i made myself wont choose the path i am saying he should choose. In my application i need to browse to a location where he needs to check what happens with the files in that location. My problem is: When i browse it wont watch the map i choose. I think he already watches before i have chosen a path. Please help. (I just started working with C# for the first time) If someone wants to help me but doesn't have enough information. (I actually have 2 other files but this one looked the best) Add me on skype: Maybeloko
Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
  public partial class Form1 : Form
  {
 
   
  public Form1()

  {
  InitializeComponent();
  }

  private void Form1_Load(object sender, EventArgs e)
  {

  }

   

  private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  {
   

  }

  private void fileSystemWatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
  {
  listBox1.Items.Add("File Created> " + e.FullPath + " -Date:" + DateTime.Now);
  }

  private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
  {
  listBox1.Items.Add("File Changed> " + e.FullPath + " -Date:" + DateTime.Now);
  }
  private void fileSystemWatcher1_Deleted(object sender, System.IO.FileSystemEventArgs e)
  {

  listBox1.Items.Add("File Deleted> " + e.FullPath + " -Date:" + DateTime.Now);

  }

  private void fileSystemWatcher1_Renamed(object sender, System.IO.RenamedEventArgs e)
  {

  listBox1.Items.Add("File Renamed> " + e.FullPath + " -Date:" + DateTime.Now);

  }

  private void fileSystemWatcher2_Changed(object sender, System.IO.FileSystemEventArgs e)
  {
  listBox1.Items.Add("File Changed> " + e.FullPath + " -Date:" + DateTime.Now);

  }

  private void fileSystemWatcher2_Created(object sender, System.IO.FileSystemEventArgs e)
  {
  listBox1.Items.Add("File Created> " + e.FullPath + " -Date:" + DateTime.Now);
  }

  private void fileSystemWatcher2_Deleted(object sender, System.IO.FileSystemEventArgs e)
  {
  listBox1.Items.Add("File Deleted> " + e.FullPath + " -Date:" + DateTime.Now);
  }

  private void fileSystemWatcher2_Renamed(object sender, System.IO.RenamedEventArgs e)
  {
  listBox1.Items.Add("File Renamed> " + e.FullPath + " -Date:" + DateTime.Now);
  }

  private void button2_Click(object sender, EventArgs e)
  {
  //
  DialogResult resDialog = dlgOpenDir.ShowDialog();
  if (resDialog.ToString() == "OK")
  {
  textBox1.Text = dlgOpenDir.SelectedPath;
  }
  }

  private void button3_Click(object sender, EventArgs e)
  {
  DialogResult resDialog = dlgOpenDir.ShowDialog();
  if (resDialog.ToString() == "OK")
  {
  textBox2.Text = dlgOpenDir.SelectedPath;
  }
  }


  }
}