Creating a FileWriter activity
CodeActivity
is an abstract class inherited from Activity
. We can put our logic code in its Execute
method. In this task, we are going to create an activity that will write data to a text file.
How to do it...
- Create the FileWriter activity:
Add a new code file to
ActivityLibrary
project namedFileWriter.cs
. Then replace all default code with the following code:using System; using System.Activities; using System.Threading; public sealed class FileWriter : CodeActivity { [RequiredArgument] public InArgument<string> fileName { get; set; } [RequiredArgument] public InArgument<string> fileData { get; set; } protected override void Execute(CodeActivityContext context) { string lines = fileData.Get(context); // Write ...
Get Microsoft Windows Workflow Foundation 4.0 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.