Made a C# console application where I use a FileWathcerSystem to track when new files are added to a certain folder. I have added an outside DLL as reference (which I believe is AMD64 since I get error when I use x86 instead of x64).
Now, everything works so far, I can use the methods from the DLL. But, when I try to read the text from the created .txt I get the following error:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Now, when I look at the references that are added by default:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\System.Data.DataSetExtensions.dll
Does this mean it's using the x86 dll as standard?
FileSystemWatcher fwatcher = new FileSystemWatcher();
fwatcher.Path = "C:\\FileWatcher";
fwatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName;
fwatcher.Created += new FileSystemEventHandler(FileCreated);
fwatcher.EnableRaisingEvents = true;
This is the method that I try to run that is called when a new file is created )
private static void FileCreated(object sender, FileSystemEventArgs e)
{
Console.WriteLine("File created");
System.Threading.Thread.Sleep(1000);
String text = File.ReadAllText(@e.FullPath);
StringReader reader = new StringReader(text);
Console.WriteLine(e.FullPath.ToString());
Console.WriteLine(text);
}
Also, all of a sudden I get double events. I added sleep timer since I got an error that the file doesn't exist.