情况是这样的,我有一个datagridview从xml文件加载一些数据,所以,我使用一个函数加载这个信息,并在这个函数中第一行清理完整的datagridview,我正在使用FileSystemWatcher用于处理将新文件插入特定文件夹并刷新表时的事件,当我只移动或创建一个文件时它可以正常工作,但是当我将文件移动到文件夹或复制&粘贴,程序抛出一条错误消息,我认为这是因为事件是为每个复制或移动的文件触发,并且当它再次清理时它不允许完成get files方法,我不确定我是不是清楚,我将在这里告诉你代码的各个部分,它在包含GetFiles方法的类的构造函数中初始化的FileWatcher实例
GetFiles方法:
html,
body {
font: 400 16px/1.2 Consolas;
font-variant: small-caps;
width: 100%;
height: 100%;
}
.chx {
display: none
}
.lab {
display: inline-block;
margin: 10px;
cursor: pointer;
}
.lab::before {
content: '\1f518';
box-shadow: 0px 1.5px 1px 2.5px rgba(51, 51, 51, 0.3);
border-radius: 50%;
}
#c1:checked~.header .options .c1::before,
#c2:checked~.header .options .c2::before,
#c3:checked~.header .options .c3::before,
#c4:checked~.header .options .c4::before {
content: '\1f535';
box-shadow: 0px 1.5px 1px 2.5px rgba(15, 102, 241, 0.5);
}
#c0:checked~.header .c0::before,
#c0:checked+#c1:checked~.header .options .c1::before,
#c0:checked~#c2:checked~.header .options .c2::before,
#c0:checked~#c3:checked~.header .options .c3::before,
#c0:checked~#c4:checked~.header .options .c4::before {
content: '\1f534';
box-shadow: 0px 1.5px 1px 2.5px rgba(241, 102, 15, 0.5);
}
#c1:checked+#c2:checked+#c3:checked+#c4:checked+.header .c0::after {
content: ' Selected';
color: rgba(15, 102, 241, 1);
text-shadow: 1.5px 2px 1.75px rgba(15, 102, 241, 0.7);
}
#c0:checked+#c1:checked+#c2:checked+#c3:checked+#c4:checked+.header.header .c0::after {
content: ' Selected';
color: rgba(241, 102, 15, 1);
text-shadow: 1.5px 2px 1.75px rgba(241, 102, 15, 0.7);
}
#c1:not(:checked)~.header .c0::after,
#c2:not(:checked)~.header .c0::after,
#c3:not(:checked)~.header .c0::after,
#c4:not(:checked)~.header .c0::after {
content: '';
}
#c1:not(:checked)~.header .c0::before,
#c2:not(:checked)~.header .c0::before,
#c3:not(:checked)~.header .c0::before,
#c4:not(:checked)~.header .c0::before {
content: '\1f518';
box-shadow: 0px 1.5px 1px 2.5px rgba(51, 51, 51, 0.3);
}
.header {
border: 3px inset rgba(51, 51, 51, 0.51);
border-radius: 5px;
-webkit-padding-before: 0.0em;
-webkit-padding-start: 0.15em;
-webkit-padding-end: 0.15em;
-webkit-padding-after: 0.15em;
box-shadow: 0px 1.5px 1px 2.5px rgba(51, 51, 51, 0.3);
width: 380px;
}
legend {
height: 35px
}
legend h3 {
font-size: 1.55rem;
line-height: 2;
transform: translateY(-35px);
}
.options {
background: rgba(3, 9, 27, 0.1);
border: 3px inset rgba(51, 51, 51, 0.15);
border-radius: 5px;
box-shadow: 0px -2px -1px 0px rgba(51, 51, 51, 0.15);
}
summary {
padding: 3px 5px;
font-size: 1.2rem;
cursor: pointer;
}
FileWatcherClass:
<form id='card'>
<input type="checkbox" class="chx" id="c0" />
<input type="checkbox" class="chx" id='c1' />
<input type="checkbox" class="chx" id='c2' />
<input type="checkbox" class="chx" id='c3' />
<input type="checkbox" class="chx" id='c4' />
<fieldset class='header' name="header">
<legend>
<h3>List of Checkboxes</h3>
</legend>
<label for='c0' class='c0 lab'> All Options</label>
<details class="options">
<summary>Select Options</summary>
<label for='c1' class='c1 lab'> One </label>
<label for='c2' class='c2 lab'> Two </label>
<label for='c3' class='c3 lab'> Three </label>
<label for='c4' class='c4 lab'> Four </label>
</details>
</fieldset>
</form>