Write string to file via Method Directive tools?

I need to write a string to a file for Bartender to trigger a label print. We already have this ability in another method directive which runs a bunch of custom code to do so, but it seems overly complicated and possibly not best for upgrades.

In an attempt to better utilize more of the base tools in the Workflow Designer, is there a way to write a string (query result) to a text file on the server?

In a BPM you can use custom code to do this

I use this little snippet to fill out my data and then write to a file if Iā€™m debugging a BPM
Replace the server with your app server.

//debug testing
  string path = @"\\<server>\C$\Temp\BPMDebugger.txt";
  string content = "your string here";
   if(!File.Exists(path))
   {
   // Create a file to write to.
    string createText = "First Line:" + Environment.NewLine;
  File.WriteAllText(path, createText);
   }
   string appendText = Environment.NewLine + "Response: "+DateTime.Now.ToString() + Environment.NewLine + content;
   File.AppendAllText(path, appendText);
2 Likes

@Adam I use StreamWriter to do this. I am sure the code came from here somewhere.

var fileLocation = "\\server\share\file";
var outputLine = "stuff";

  using (var TCFile = new System.IO.StreamWriter(@fileLocation, true))
                  
        {
           TCFile.WriteLine(outputLine);
           TCFile.Close();
        }   


1 Like