예제 #1
0
        public async Task CreateFolder(string folderPath)
        {
            await Task.Run(() => _fileExplorerCommand.CreateFolder(folderPath));

            var parentFolder = Path.GetDirectoryName(folderPath);

            var entry = new PackedDirectoryEntry
            {
                CreationTime = DateTime.Now,
                HasSubFolder = false,
                Name         = new DirectoryInfo(folderPath).Name,
                Path         = folderPath
            };

            if (parentFolder != null && _cachedEntries.TryGetValue(parentFolder.NormalizePath(), out var entriesInfo))
            {
                entry.Parent = entriesInfo.DirectoryEntry;
                entriesInfo.DirectoryEntry.HasSubFolder = true;

                lock (entriesInfo)
                    entriesInfo.Entries.Add(entry);
                FileExplorerEntryAdded?.Invoke(this, new EntryAddedInfo(entry, entriesInfo.DirectoryEntry.Path));
            }
            else
            {
                FileExplorerEntryAdded?.Invoke(this, new EntryAddedInfo(entry, parentFolder));
            }
        }
예제 #2
0
        public async Task CreateShortcut(string path, ShortcutInfo shortcutInfo)
        {
            await Task.Run(() => _fileExplorerCommand.CreateShortcut(path, shortcutInfo));

            var         parentFolder = Path.GetDirectoryName(path);
            EntriesInfo entriesInfo;
            var         newEntry = new FileEntry
            {
                CreationTime = DateTime.Now,
                Name         = Path.GetFileName(path),
                Path         = path,
                Size         = 0
            };

            if (_cachedEntries.TryGetValue(parentFolder.NormalizePath(), out entriesInfo))
            {
                newEntry.Parent = entriesInfo.DirectoryEntry;
                lock (newEntry)
                    entriesInfo.Entries.Add(newEntry);
            }

            FileExplorerEntryAdded?.Invoke(this, new EntryAddedInfo(newEntry, parentFolder));
        }