Roy Guzman

Roy Guzman

  • NA
  • 18
  • 1.9k

how to find all files to another destination

Jul 18 2017 10:33 AM
I have a file path pointing to a text file on disk, I want to write the details of every file within c:\temp\ overwriting any exisiting text. 
this should be in the format ( "<fullName> : <name>" ) Each file data should be on a new line and teh files of all sub-directories should be included.
 
 
here is what I have done so far
 
 
public static void WriteAllFileDataToDisk(string filePath)
{
var myfile = filePath.AsFile();
var listoffiles = "c:\\temp\\".AsDirectory().GetFiles(true);
foreach (var y in listoffiles)
{
myfile.WriteAllText("{0} : {1}".FormatWith(y.AsFile().FullName, y.AsFile().Name));
}
}
 
it is not working correctly. please let know if you can help. 

Answers (2)