我需要将一个目录中找到的文件与另一个目录中的文件进行比较,并将目录中找到的新文件打印到控制台中。我已经设置好了,所以它需要文件并将其分配给一个变量。另一个目录被分配给另一个变量。如何将变量之一中的新数据打印到命令提示符?我使用的语言是 c#。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;namespace ConsoleApp1{ class Program { static void Main(string[] args) { Console.Write("Write the path of the old file folder: "); string path = Console.ReadLine(); listFilesFromDirectory(path); Console.Write("Write the path of the new file folder: "); string pathTwo = Console.ReadLine(); listFilesFromDirectoryMore(pathTwo); Console.WriteLine("Press Enter to continue:"); Console.Read(); } static void listFilesFromDirectory(string workingDirectory) { // get a list of files in a directory, // based upon a path that is passed into the function string[] filePaths = Directory.GetFiles(workingDirectory); foreach (string filePath in filePaths) { // use the foreach loop to go through the entire // array one element at a time write out // the full path and file name of each of the // elements in the array Console.WriteLine(filePath); string oldfile = (filePath); } } }}
1 回答
- 1 回答
- 0 关注
- 162 浏览
添加回答
举报
0/150
提交
取消