Exemple #1
0
        static bool MoveFile(List <FileIndexInfo> FileListCache, string file,
                             FileIndexInfo f, string destinationFolderPath, string destinationFilePath)
        {
            bool updateFileListJsonFile;

            ConsoleLog(String.Format("Moving File {0}({1}) to {2}.", f.FileName, f.MD5Checksum,
                                     destinationFolderPath));
            File.Move(file, destinationFilePath);
            FileListCache.Add(f);
            updateFileListJsonFile = true;
            ConsoleLog(String.Format("File {0}({1}) was moved to {2}.", f.FileName, f.MD5Checksum,
                                     destinationFolderPath));
            return(updateFileListJsonFile);
        }
Exemple #2
0
        static FileIndexInfo ConvertToFileIndex(string FilePath)
        {
            string fileName      = Path.GetFileName(FilePath);
            string fileExtension = "";

            if (Path.GetExtension(FilePath).StartsWith('.'))
            {
                fileExtension = Path.GetExtension(FilePath).Substring(1);
            }

            FileIndexInfo rFileIndexInfo = new FileIndexInfo();

            rFileIndexInfo.MD5Checksum   = CalculateMD5(FilePath);
            rFileIndexInfo.FileName      = fileName;
            rFileIndexInfo.FileExtension = fileExtension;
            rFileIndexInfo.FilePath      = FilePath;
            rFileIndexInfo.CreatedOnDate = File.GetCreationTime(FilePath);
            rFileIndexInfo.UpdatedOnDate = File.GetLastWriteTime(FilePath);

            ReadXMPFile(rFileIndexInfo);

            return(rFileIndexInfo);
        }
Exemple #3
0
        static void ReadXMPFile(FileIndexInfo FileIndex)
        {
            string directoryName = Path.GetDirectoryName(FileIndex.FilePath);
            string fileName      = Path.GetFileNameWithoutExtension(FileIndex.FilePath);
            string xmpFileName   = fileName + ".xmp";
            string xmpFilePath   = String.Format("{0}/{1}", directoryName, xmpFileName);

            if (File.Exists(xmpFilePath))
            {
                FileIndex.CreatedOnDateFromXMP = new List <DateTime>();
                Console.WriteLine("Reading Created On Date from XMP : {0}", xmpFilePath);
                XDocument doc = XDocument.Load(xmpFilePath);

                //     XNamespace ns = XNamespace.Get("adobe:ns:meta/");
                //     var listOfNames = doc.Descendants(ns + "xmpmeta")
                //              .Select(x => x.Elements().First().Value).ToList();
                //    Console.WriteLine (JsonConvert.SerializeObject(listOfNames));

                var query = doc.Descendants()
                            .Where(c => c.Name.LocalName.ToString() == "DateCreated")
                            .ToArray();

                foreach (String item in query)
                {
                    FileIndex.CreatedOnDateFromXMP.Add(Convert.ToDateTime(item));
                    //Console.WriteLine(item);
                }

                //Apply the Changes got from the XMP File
                if (FileIndex.CreatedOnDateFromXMP.FirstOrDefault() != null)
                {
                    FileIndex.CreatedOnDateFromFile = FileIndex.CreatedOnDate;
                    FileIndex.CreatedOnDate         = FileIndex.CreatedOnDateFromXMP.FirstOrDefault();
                    FileIndex.FileName = String.Format("{0:yyyyMMddhhmmss}-{1}", FileIndex.CreatedOnDate, FileIndex.FileName);
                }
            }
        }