Exemplo n.º 1
0
        private async void btnLoad_Click(object sender, EventArgs e)
        {
            SetState(AppState.Loading);

            m_LoadCancelSource = new CancellationTokenSource();

            var localFolder = new LocalFolder(m_LoadSettings);

            localFolder.LoadProgress += LocalFolderOnLoadProgress;

            await localFolder.Load(m_LoadCancelSource.Token);

            localFolder.LoadProgress -= LocalFolderOnLoadProgress;

            if (m_LoadCancelSource.IsCancellationRequested)
            {
                lblFilesFound.Text += " (Cancelled)";
                SetState(AppState.Unloaded);
            }
            else
            {
                var exactDupes = localFolder.GetExactDupes();
                listLog.Items.Add($"Exact dupes found: {exactDupes.Count}");
                if (exactDupes.Count > 0)
                {
                    listLog.Items.AddRange(exactDupes.Select(f => (object)$"{f.File.Name} [{f.File.Length} bytes] {f.File.FullName}").ToArray());
                }

                var sizeDupes = localFolder.GetSizeDupes();
                listLog.Items.Add($"Size dupes found: {sizeDupes.Count}");
                if (sizeDupes.Count > 0)
                {
                    listLog.Items.AddRange(sizeDupes.Select(f => (object)$"{f.File.Name} [{f.File.Length} bytes] {f.File.FullName}").ToArray());
                }

                var nameDupes = localFolder.GetNameDupes();
                listLog.Items.Add($"Name dupes found: {nameDupes.Count}");
                if (nameDupes.Count > 0)
                {
                    listLog.Items.AddRange(nameDupes.Select(f => (object)$"{f.DisplayName} [{f.File.Length} bytes] {f.File.FullName}").ToArray());
                }

                m_LoadedRootFolder = localFolder;
                SetState(AppState.Loaded);
            }
        }