Esempio n. 1
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker      = (BackgroundWorker)sender;
            string           pathSortida = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "SORTIDA");

            Contador = 1;

            bool existeix = Directory.Exists(pathSortida);

            if (!existeix)
            {
                Directory.CreateDirectory(pathSortida);
            }

            //Buidar la carpeta
            DirectoryInfo di = new DirectoryInfo(pathSortida);

            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }

            using (ExifToolWrapper extw = new ExifToolWrapper())
            {
                extw.Start();

                string linea;



                // Append text to an existing file named "WriteLines.txt".
                string temporal  = Path.Combine(Path.GetDirectoryName(RutaImatges), "index.txt");
                string pathIndex = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "SORTIDA");

                using (StreamWriter outputFile = new StreamWriter(pathIndex + "\\index.txt", true))
                {
                    foreach (FotoModel foto in Fotos)
                    {
                        try
                        {
                            linea = foto.Client + foto.Expedient + foto.Arxiu_foto;
                            outputFile.WriteLine(linea);
                            d = extw.FetchExifFrom(_rutaImatges + "\\" + foto.Arxiu_foto);
                            d.TryGetValue("Comment", out result);
                            metadades = result.Split(separationString, System.StringSplitOptions.RemoveEmptyEntries);

                            Utils.EscriureText(metadades, _rutaImatges + "\\" + foto.Arxiu_foto, foto.Arxiu_foto);
                            Contador++;
                        } catch (Exception ex)
                        {
                            continue;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
    public ExIF(string FiletoScan, ref XMLParser raport)
    {
        Dictionary <string, string> d;

        using (var etw = new ExifToolWrapper(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\exiftool(-k).exe"))
        {
            etw.Start();
            d = etw.FetchExifFrom(FiletoScan);
            if (!d.ContainsKey("Error"))
            {
                d.Remove("ExifTool Version Number");
                d.Remove("File Name");
                d.Remove("Directory");
                d.Remove("File Size");
                d.Remove("File Modification Date/Time");
                d.Remove("File Access Date/Time");
                d.Remove("File Creation Date/Time");
                d.Remove("File Permissions");
                raport.AddExIF(d);
            }
        }
    }
        // Use the ExifToolWrapper to load all the metadata
        // Note that this requires the exiftool(-k).exe to be available in the executables folder
        private void LoadExif()
        {
            extw = new ExifToolWrapper();
            extw.Start();

            dictMetaDataLookup = extw.FetchExifFrom(System.IO.Path.Combine (folderPath, fileName));
            this.dg.ItemsSource = dictMetaDataLookup; // Bind the dictionary to the data grid. For some reason, I couldn't do this in  xaml
        }