コード例 #1
0
ファイル: Directory.cs プロジェクト: DronLee/DirectorySync
        public async Task CopyTo(string destinationPath)
        {
            await Task.Run(async() =>
            {
                try
                {
                    IO.Directory.CreateDirectory(destinationPath);
                }
                catch { }

                foreach (var item in _items)
                {
                    await item.CopyTo(IO.Path.Combine(destinationPath, item.Name));
                }

                CopiedFromToEvent?.Invoke(_itemFactory.CreateDirectory(destinationPath, ExcludedExtensions), destinationPath);
            }).ConfigureAwait(false);
        }
コード例 #2
0
        /// <summary>
        /// Копировать элемент в указанный путь с заменой.
        /// </summary>
        /// <param name="destinationPath">Путь куда копировать.</param>
        public async Task CopyTo(string destinationPath)
        {
            await Task.Run(() =>
            {
                try
                {
                    IO.File.Copy(FullPath, destinationPath, true);
                }
                catch (Exception exc)
                {
                    SyncErrorEvent?.Invoke(exc.Message);
                }

                File destinationFile = null;
                try
                {
                    destinationFile = new File(destinationPath);
                }
                catch { }
                CopiedFromToEvent?.Invoke(destinationFile, destinationPath);
            }).ConfigureAwait(false);
        }
コード例 #3
0
 private void CopiedFromTo(IItem newItem, string destinationPath)
 {
     CopiedFromToEvent?.Invoke(this, newItem);
 }