Exemple #1
0
        private static void GetFiles(string Path, SortedDictionary <DateTime, FileInformation> Sorted)
        {
            string[] Files = Directory.GetFiles(Path, "*.*", SearchOption.TopDirectoryOnly);
            int      i, c = Files.Length;
            DateTime Created;
            long     Size;
            string   SizeStr;
            string   s;

            Path += System.IO.Path.DirectorySeparatorChar;

            for (i = 0; i < c; i++)
            {
                s = Files[i];

                try
                {
                    using (FileStream fs = File.OpenRead(s))
                    {
                        Size    = fs.Length;
                        SizeStr = FormatBytes(Size);
                    }
                }
                catch (Exception ex)
                {
                    Log.Critical(ex);
                    Size    = 0;
                    SizeStr = string.Empty;
                }

                Created = File.GetCreationTime(s);

                if (s.StartsWith(Path))
                {
                    s = s.Substring(Path.Length);
                }

                while (Sorted.ContainsKey(Created))
                {
                    Created = Created.AddTicks(1);
                }

                Sorted[Created] = new FileInformation(s, Created, Size, SizeStr);
            }
        }