private void textboxTrainFolder_TextChanged(object sender, EventArgs e)
{
if (listviewTrainFolders.Columns.Count == 0)
{
return;
}
string Folder = textboxTrainFolder.Text;
while (!Directory.Exists(Folder) && Path.IsPathRooted(Folder))
{
Folder = Directory.GetParent(Folder).ToString();
}
if (tf != Folder)
{
populateTrainList(Folder);
}
tf = Folder;
try
{
trainWatcher = new FileSystemWatcher();
trainWatcher.Path = Folder;
trainWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
trainWatcher.Filter = "*.*";
trainWatcher.Changed += onTrainFolderChanged;
trainWatcher.EnableRaisingEvents = true;
}
catch
{
}
listviewTrainFolders.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
}