-
Notifications
You must be signed in to change notification settings - Fork 1
IFile
IFile
is a class representing single file. It contains properties and methods to perform typical files-related tasks.
Gets file "absolute" path. It is the path the file was originaly created with:
IFile solutionFile = "C:/Projects/MyProject.sln";
string path = solutionFile.AbsolutePath; // path is C:/Projects/MyProject.sln
...or the path derived from parent directory:
IDirectory src = "C:/Projects/MyProject"
IFile solutionFile = src/"MyProject.sln";
string path = solutionFile.AbsolutePath; // path is C:/Projects/MyProject/MyProject.sln
There is an implicit to string
conversion operation that returns AbsolutePath
so the call to this property could be omited:
IFile solutionFile = "C:/Projects/MyProject.sln";
// implicit conversion
string path = solutionFile; // path is C:/Projects/MyProject.sln
Gets the flag indicating whether the file exists.
IFile solutionFile = "C:/Projects/MyProject.sln";
bool solutionFileExists = solutionFile.Exists;
Gets file name with extension without preceding path.
IFile solutionFile = "C:/Projects/MyProject.sln";
string fileName = solutionFile.Name; // MyProject.sln
Gets file name without extension.
IFile solutionFile = "C:/Projects/MyProject.sln";
string fileName = solutionFile.NameWithoutExtension; // MyProject
Gets file reading stream.
IFile dataFile = "C:/Projects/data.txt";
using(var reader = new StreamReader(dataFile.ReadStream))
{
// reading data
}
Gets file writing stream.
IFile dataFile = "C:/Projects/data.txt";
using (var writer = new StreamWriter(dataFile.WriteStream))
{
// writing data
}
Gets an object of type ExtensionInfo
that encapsulates information about file extension.
Gets size of the file in bytes.
Gets parent directory object (IDirectory
) of the file.
Creates file (and it's parent directory) if it does not exist.
IFile dataFile = "C:/Projects/data.txt";
// creates C:/Projects (if it does not exist)
// directory and empty data.txt file:
dataFile.EnsureExists();
Deletes the file.
Calclulates relative path from provided directory
to current file.
IFile file = "C:/A/B/file.txt";
IDirectory dir = "C:/A/D";
string relativeFilePath = file.GetRelativePath(dir); // "../B/file.txt"
Writing Tasks
- Creating a Workflow
- Defining Tasks
- Share State accross Tasks
- Mastering Dependencies
- Using result transformers
- Using Subflows to organize tasks
- Tasks Preconditions
- Recovering failure results
- Declaring dynamic tasks
- Creating Custom Tasks
Running Tasks
API
Tasklib