Пример #1
0
        private void OnDeleted(object source, FileSystemEventArgs e)
        {
            if (!FileSystemUtilities.ExtensionIsSupported(e.FullPath) || !FileSystemUtilities.fileIsImportant(e.FullPath) || FileSystemUtilities.isTemporaryFile(e.FullPath))
            {
                return;
            }
            String fileName = FileSystemUtilities.ExtractNameFromPath(e.Name);

            // This is done to account for move events
            nameOfDeletedFile = fileName;
            pathOfDeletedFile = e.FullPath;
        }
Пример #2
0
        private void OnCreated(object source, FileSystemEventArgs e)
        {
            if (!FileSystemUtilities.ExtensionIsSupported(e.FullPath) || !FileSystemUtilities.fileIsImportant(e.FullPath))
            {
                return;
            }
            Console.WriteLine("You moved {0} and the deleted file last was {1}", e.Name, nameOfDeletedFile);
            String fileName = FileSystemUtilities.ExtractNameFromPath(e.Name);

            if (fileName.Equals(nameOfDeletedFile))
            {
                Console.WriteLine("You moved {0}", e.Name);
                events.Enqueue(new Event(fileName, pathOfDeletedFile, e.FullPath, FileSystemUtilities.EVENT_ACTIONS.move));
            }
        }
Пример #3
0
        private void OnRenamed(object source, RenamedEventArgs e)
        {
            if (!FileSystemUtilities.ExtensionIsSupported(e.FullPath) || !FileSystemUtilities.fileIsImportant(e.FullPath))
            {
                return;
            }

            // If any temp file was renamed, send a modify event
            String oldFileName = FileSystemUtilities.ExtractNameFromPath(e.OldName);

            Console.WriteLine(oldFileName);
            if (FileSystemUtilities.isTemporaryFile(oldFileName))
            {
                events.Enqueue(new Event(FileSystemUtilities.ExtractNameFromPath(e.Name), e.FullPath, FileSystemUtilities.EVENT_ACTIONS.modify));
                return;
            }

            // Otherwise, it is a normal rename event so send a put request
            if (FileSystemUtilities.fileIsImportant(e.FullPath))
            {
                Console.WriteLine(FileSystemUtilities.ExtractNameFromPath(e.FullPath) + "|" + e.FullPath);
                events.Enqueue(new Event(FileSystemUtilities.ExtractNameFromPath(e.FullPath), e.OldFullPath, e.FullPath, FileSystemUtilities.EVENT_ACTIONS.rename));
            }
        }
Пример #4
0
        public static void CopyFile(File file, String destination)
        {
            Console.WriteLine("Currently Processing: " + file.Name);
            destination = String.Concat(destination, file.Name);
            String source = file.Path;

            // Does destination file exist?
            // Don't copy if the last modified date of the file is the same as what is present in the directory

            if (!SystemFile.Exists(destination) || SystemFile.GetLastWriteTime(destination) <= SystemFile.GetLastWriteTime(source) && FileSystemUtilities.ExtensionIsSupported(source))
            {
                try
                {
                    System.IO.File.Copy(source, destination, true);
                }
                catch
                {
                    Console.WriteLine("Couldn't copy at this time");
                    Console.WriteLine(source + "|" + destination);
                }
            }
        }