O'Reilly logo

Microsoft Windows Workflow Foundation 4.0 Cookbook by Andrew Zhu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  1. Create the FileWriter activity:

    Add a new code file to ActivityLibrary project named FileWriter.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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required