我们如何从文件夹中的文件数中选择一个随机文件,并将随机文件存储到另一个文件夹中 [英] how can we select a random file from number of files in a folder and store the random file into another folder
本文介绍了我们如何从文件夹中的文件数中选择一个随机文件,并将随机文件存储到另一个文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
子文件夹中的所有文件,它们是pdf文件
all files in a subfolder and they are pdf files
推荐答案
1。使用 Io.Directory.GetFiles [ ^ ]
从目录中获取文件列表
2. 生成随机数 [ ^ ]介于0和文件数之间
3.将得到的数字作为文件集合中的文件索引并将其复制。
1. Use Io.Directory.GetFiles[^]
to get a list of files from a directory
2. Generate random number[^] between 0 and number of files
3. Take resulting number as index of a file from file collection and copy it.
这篇关于我们如何从文件夹中的文件数中选择一个随机文件,并将随机文件存储到另一个文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文