From 1c140cb3124b0d70e4d891299976470fec5c05a2 Mon Sep 17 00:00:00 2001 From: Brychan Dempsey Date: Wed, 6 Oct 2021 15:20:12 +1300 Subject: [PATCH] Added solution files --- Watcher.sln | 25 ++++++++++++ Watcher/App.config | 6 +++ Watcher/Program.cs | 62 ++++++++++++++++++++++++++++++ Watcher/Properties/AssemblyInfo.cs | 36 +++++++++++++++++ Watcher/Watcher.csproj | 53 +++++++++++++++++++++++++ 5 files changed, 182 insertions(+) create mode 100644 Watcher.sln create mode 100644 Watcher/App.config create mode 100644 Watcher/Program.cs create mode 100644 Watcher/Properties/AssemblyInfo.cs create mode 100644 Watcher/Watcher.csproj diff --git a/Watcher.sln b/Watcher.sln new file mode 100644 index 0000000..07a628b --- /dev/null +++ b/Watcher.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.106 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Watcher", "Watcher\Watcher.csproj", "{3A92F531-9116-4780-8CF9-6F66B234F59F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3A92F531-9116-4780-8CF9-6F66B234F59F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A92F531-9116-4780-8CF9-6F66B234F59F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A92F531-9116-4780-8CF9-6F66B234F59F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A92F531-9116-4780-8CF9-6F66B234F59F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D18805AF-48E2-4AE7-8887-89F158C67741} + EndGlobalSection +EndGlobal diff --git a/Watcher/App.config b/Watcher/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/Watcher/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Watcher/Program.cs b/Watcher/Program.cs new file mode 100644 index 0000000..2e398a3 --- /dev/null +++ b/Watcher/Program.cs @@ -0,0 +1,62 @@ +using System; +using System.IO; +using System.Security.Permissions; + +public class Watcher +{ + + public static void Main() + { + Run(); + Console.ReadKey(); + } + + [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] + public static void Run() + { + string[] args = System.Environment.GetCommandLineArgs(); + + // If a directory is not specified, exit program. + if (args.Length != 2) + { + // Display the proper way to call the program. + Console.WriteLine("Usage: Watcher.exe (directory)"); + return; + } + + // Create a new FileSystemWatcher and set its properties. + FileSystemWatcher watcher = new FileSystemWatcher(); + watcher.Path = args[1]; + /* Watch for changes in LastAccess and LastWrite times, and + the renaming of files or directories. */ + watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; + watcher.Filter = "*"; + watcher.IncludeSubdirectories = true; + + // Add event handlers. + watcher.Changed += new FileSystemEventHandler(OnChanged); + watcher.Created += new FileSystemEventHandler(OnChanged); + watcher.Deleted += new FileSystemEventHandler(OnChanged); + watcher.Renamed += new RenamedEventHandler(OnRenamed); + + // Begin watching. + watcher.EnableRaisingEvents = true; + + // Wait for the user to quit the program. + Console.WriteLine("Press \'q\' to quit the sample."); + while (Console.Read() != 'q') ; + } + + // Define the event handlers. + private static void OnChanged(object source, FileSystemEventArgs e) + { + // Specify what is done when a file is changed, created, or deleted. + Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType); + } + + private static void OnRenamed(object source, RenamedEventArgs e) + { + // Specify what is done when a file is renamed. + Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath); + } +} diff --git a/Watcher/Properties/AssemblyInfo.cs b/Watcher/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d3ba376 --- /dev/null +++ b/Watcher/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Watcher")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Watcher")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3a92f531-9116-4780-8cf9-6f66b234f59f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Watcher/Watcher.csproj b/Watcher/Watcher.csproj new file mode 100644 index 0000000..5eac87e --- /dev/null +++ b/Watcher/Watcher.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {3A92F531-9116-4780-8CF9-6F66B234F59F} + Exe + Watcher + Watcher + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file