I would like to show the the new filePaths when watcher.created detects there is a new dll
I am able to set the values from watcher_change() on initial load but I am not sure how to change the listed from that point. When I use created by watcher_change(object sender, FileSystemEventArgs e) I can see that filePaths has the values I need, I am just not sure how to get them to display on screen.
public partial class Page : UserControl
{
private FileWatch f = new FileWatch();
public Page()
{
ListBox.DataContext = f.watcher_change();
}
}
public class FileWatch
{
public FileWatch()
{
var watcher =
new FileSystemWatcher {Path = @"C:\", EnableRaisingEvents = true};
watcher.Created += (o, args) => watcher_change(o, args);
}
public string[] watcher_change(object sender, FileSystemEventArgs e)
{
string[] filePaths = Directory.GetFiles(@"C:\", "*.dll");
return filePaths;
}
public string[] watcher_change()
{
string[] filePaths = Directory.GetFiles(@"C:\", "*.dll");
return filePaths;
}
}