Problems with installation

Jul 12, 2016 at 4:07 PM
Edited Jul 12, 2016 at 4:47 PM
So, I tried looking for existing threads, reviews, or an installation guide on this site and through google (although all I get are links to smartwatches on their). All I'm trying to do is follow the example and create a destination folder that will get a copy of the files as they are created on the source. I'm just testing SmartWatcher for now.

I'm having some trouble with installing it. I've outlined the steps for installation based on what I've read in case I'm missing a step.
  1. Download current version (SmartWatcher 1.3.0.0) EDIT: Tried again with the version on github, it still doesn't work.
  2. Build and Compile (using Visual Studio 2013)
  3. Install Service (right click->run as admin on \bin\debug\SmartWatcher.exe)
  4. Modify User Permissions in SmartWatcher folder to allow the “users,” LOCAL SERVICE and NETWORK SERVICE to have permissions. (to fix this error that I was getting when trying to start the service.
  5. Create a new Library with a .cs file that matches the example in the downloaded code.
  6. Modify the source path for triggering and add a destination path for copying
  7. Compile and copy the .dll file to the SmartWatcher/bin/Debug/PlugIn folder
  8. Rename the .dll to .plug
  9. Start the SmartWatcher Service (requires step 4 or it will give an error)
  10. Should be working now… but it's not and it doesn't produce any logs on windows logger
here is my code for the plug-in:
        public bool FileCreated(string filePath)
        {
            bool result = true;
            string fileName = "test.txt";
            string destFilePath = "test.txt";

            // if a file is created, copy it to the destination folder.
            if (Directory.Exists(filePath))
            {
                // Use static path methods to extract only the file name from the path.
                fileName = Path.GetFileName(filePath);
                // build destination file path from source file name and destination path
                destFilePath = Path.Combine(_strDestinationPath, fileName);
                // copy file to destination using full path
                File.Copy(filePath, destFilePath, true);
            }
            else
            {
                Console.WriteLine("Source path does not exist!");
            }

            return result;
        }
If anyone can provide assistance, that would be great, Thank you!
Coordinator
Jul 13, 2016 at 11:24 AM
did you tried to debug the service and go step by step with the events
use
System.Diagnostics.Debugger.Launch();
and check how what happen also check the log or create your own logs
Jul 14, 2016 at 1:54 PM
I made the mistake of assuming that you were using Windows event logs instead of logging the events in a file, it looks like Smart Watcher was working correctly. Now I'm able to step through the application in the debugger until the point when the new thread is spawned that I believe handles the execution of my plug-in. When I try to step into it, visual studio says there is no source code for it so I can't step through the thread.

I have attempted to add the event logger to the plug-in and windows form dialog boxes to attempt to see if the function in the plug-in is triggered, neither has worked.

Is there a more detailed example for one of the event function in the plug-in?

Thank you
Jul 14, 2016 at 4:40 PM
Edited Jul 14, 2016 at 4:44 PM
I guess it's not possible to track a thread's execution. From the output to the console though it looks like the problem was giving the application permissions to the folder.

However the thread still won't execute the event function. At this point it's incredibly simple and should work.
 public bool FileCreated(string filePath)
        {
            Console.WriteLine("Thread Entered Plugin1_FileCreated(): " + filePath);
            return true;
        }
But it never prints that to the output window.

So I'm stuck again.
Jul 14, 2016 at 7:17 PM
It looks like Console.WriteLine() does not display in the output window of the debugger, so I used Debug.WriteLine() instead and I finally got output. After some quick debugging I found an issue with my code. I used Directory.Exists() when I should have used File.Exists().
I feel dumb.
Marked as answer by mpurnyn on 7/14/2016 at 11:18 AM