C#如何递归列出一个目录下的所有文件并将所有文件复制到另一个目录
我正在尝试编写可递归读取某个文件夹的 ac# 控制台应用程序。 这些文件夹中有数千张 .jpg 图像。
文件夹结构在某些级别上非常深,示例如下所示:
Scc-LocalPhoto/testfiles/1997/JAN-JUN 1997/1997年4月/7.4.97 - 11.4.97/FRI11.4.97/
正如你所看到的,文件夹结构相当混乱,但我无法控制它。
我的任务是通读所有文件夹。从图像中提取元数据并存储在 XML 文件中。然后,我需要复制同一布局中的所有文件夹并将它们粘贴到新文件夹中。
我想我将能够读取所有目录并从图像中提取元数据并将其保存到 xml 文件中。
我不知道该怎么做是复制并粘贴所有文件夹和图像,并将它们粘贴到保持相同文件夹结构的新目录中。
有谁知道执行此任务的有效方法,或者是否有任何可用的项目、代码我可以用作起点。
我对 C# 和编写控制台应用程序相当陌生。 感谢您抽出时间。
I am trying to write a c# console application that recursively reads through a certain folder.
In these folders are thousands of .jpg images
The folder structure is very deep in some levels and an example look like this:
Scc-LocalPhoto/testfiles/1997/JAN-JUN
1997/APRIL 1997/7.4.97 -
11.4.97/FRI11.4.97/
As you can see the folder structure is quite messy, however I do not have control over this.
My task is to read through all the folders. Retract the Meta data from the images and store in XML file. I then need to copy all the folders in the same layout and paste them in a new folder.
I think I will be able to read though all the directories and extract the meta data from the images and save it to an xml file.
What I do not know how to do is copy and past all the folders and images and paste them in a new directory maintaining the same folder structure.
Does anybody know of an efficient way to perform this task or is there any project, code available I could use as a starting point.
I am fairly new to C# and writing console apps.
Thanks for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
递归解析目录
处理目录中的文件
复制目录树
示例用法
希望这有帮助!
Parsing Directories Recursively
Processing the Files in a Directory
Copying a Directory tree
Sample usage
Hope this helps!
我可以提出以下建议吗?在我看来,这更简单一些
May I suggest the following, which is, in my opinion, a little bit more straightforward