Given a carriage return delimited text file say of folder names, how do I read this file into List in the Cake build system for C#?
When I try to use the File class, it complains that File(string) is a method, which is not valid given the context:
filePath filePath;
string fileContents = File.ReadAllText(filePath FullPath);
How would I write this so it works with Cake?
Cake has its own File
class, so there's a namespace conflict where the compiler doesn't know which File
class you want to use.
You have to fully-qualify the type name in your call, to include the System.IO
namespace:
filePath filePath;
string fileContents = System.IO.File.ReadAllText(filePath FullPath);
You might also be interested in the Cake.FileHelpers addin which adds a set of aliases for Cake to help with simple file operations such as Reading, Writing and Replacing text.