1
Answer

FileSystemWatcher and moving directories

Chris B

Chris B

20y
1.9k
1
I have created a FileSystemWatcher which monitors d:\stage. When i move a directory, say c:\project, into the D:\stage directory, I get a FileCreated event only for the directory name "project". I am more interested in the .txt files that are within the 'project' directory, but Create events do not seem to get fired for files within "project". And i do have the SubFolders attribute turned on with the FileSystemWatcher. After i move the C:\project into D:\stage, I can then add any .txt files i want to d:\stage\project and the events fire. The events just don't fire when a whole directory is moved into d:\stage. Has anyone else seen this, is there a workaround?
Answers (1)
2
Deepak Verma
NA 1.7k 690.4k 12y

Attachment menudemo.zip

Hi Dinesh,

Refer to this code:

Master Page:

<head runat="server">
  <title></title>
 
  <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
 
  <script src="jquery-1.6.2.js" type="text/javascript"></script>
 
  <script type="text/javascript">
 
  $(document).ready(function () {
  $(".menuLinks").click(function () {
  $(".menuLinks").removeClass("selected");
  });
  });
  </script>
 
  <asp:ContentPlaceHolder ID="head" runat="server">
 
  </asp:ContentPlaceHolder>
 </
head>
 <
body>
  <form id="form1" runat="server">
 
  <div>
 
  <ul class="menu">
 
  <li><a id="link1" class="menuLinks" href="Page1.aspx" runat="server">Link 1</a></li>
 
  <li><a id="link2" class="menuLinks" href="Page2.aspx" runat="server">Link 2</a></li>
 
  <li><a id="link3" class="menuLinks" href="Page3.aspx" runat="server">Link 3</a></li>
 
  </ul>
 
  <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
 
  </asp:ContentPlaceHolder>
 
  </div>
 
  </form>
 </
body>
 

StyleSheet.css :

ul.menu li
 
{
  float: left;
  list-style: none;
 }
 ul.menu
li a
 
{
  text-decoration: none;
  font-family: Tahoma;
  font-size: 20px;
  margin: 0px 10px 0px 0px;
  padding: 3px;
  background-color: Black;
  color: White;
  border-radius: 5px;
 }
 ul.menu li a:hover
 
{
  background-color: Blue !important;
 }
 ul.menu li a.selected
 
{
  background-color: Blue !important;
 } 

Page1.aspx.cs :

 protected void Page_Load(object sender, EventArgs e)
  {
  ((HtmlAnchor)this.Page.Master.FindControl("link1")).Attributes.Add("class", "selected");
  }

Page2.aspx.cs :

 protected void Page_Load(object sender, EventArgs e)
  {
  ((HtmlAnchor)this.Page.Master.FindControl("link2")).Attributes.Add("class", "selected");
  }

Page3.aspx.cs :

 protected void Page_Load(object sender, EventArgs e)
  {
  ((HtmlAnchor)this.Page.Master.FindControl("link3")).Attributes.Add("class", "selected");
  }

Accepted
0
Dinesh Ambaliya
NA 42 59.8k 12y
This will work. Thank you.