Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Demo20180906
- {
- class Program
- {
- [STAThread]
- static void Main(string[] args)
- {
- //Дано деяку папку A. Скопіювати усі файли розміром 100 байт і більше в папку B.
- var folderA = @"D:\ABC";
- var folderB = @"D:\ABC_New";
- var di = new DirectoryInfo(folderA);
- var files = di.GetFiles();
- if (!Directory.Exists(folderB))
- Directory.CreateDirectory(folderB);
- foreach (var file in files)
- {
- Console.WriteLine("{0} - {1}", file.Name, file.Length);
- if (file.Length>=100)
- {
- try
- {
- file.CopyTo(Path.Combine(folderB, file.Name));
- }
- catch (IOException ex)
- {
- Console.WriteLine("Error: {0} with {1}",ex.Message, file.Name);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement