The .NET methods aren't working inside custom scripts

Symptoms

Custom .NET scripts embedded into the FlexiCapture 12 Rules, stages, event handlers, that should work with files, directories, threads sometimes are not executed correctly.

Resolution

To properly execute the code that works with files/directories/threads, the user under which the Processing Station service is running, should have the permissions to access the objects used in such scripts.

For example:

StreamWriter class of the System.IO namespace works with files and directories. 

Here is a code snippet:

using System;

using System.Net;

using System.Net.Mail;

using System.IO;

using System.Collections.Generic;

    StreamWriter sw = new StreamWriter("C:\\temp\\Test.txt",true);

    //Write a line of text

    sw.WriteLine("Hello World!!");

    //Write a second line of text

    sw.WriteLine("From the StreamWriter class"+ docWithErrors.ToString());

    //Close the file

    sw.Close();

If the Processing Station is run under Network Service:

2021-07-12_13_36_26-Services.png

then the folder "C:\temp" and file "Test.txt" used in the script should have read & write permissions granted to the Network Service. 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.

Recently viewed