我需要一个简单的函数,它将 FileInfo 和 destination_directory_name 作为输入,从 fileinfo 获取文件路径并将其复制到作为第二个参数传递的 destination_directory_name 中。
例如。文件路径是“d:\recordings\location1\client1\job1\file1.ext 如果目录不存在,该函数应在 destination_directory_name 中创建目录,并在创建目录后复制文件。
最佳答案
System.IO.Directory.CreateDirectory 可用于创建最终目录,如果路径中的所有文件夹不存在,它也会自动创建。
//Will create all three directories (if they do not already exist).
System.IO.Directory.CreateDirectory("C:\\First\\Second\\Third")
关于c# - 在文件路径中复制文件夹结构的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/438321/