create file and write ascii lines to it - help
I need to create a temporary file that can be downloaded by the user.
the file should will contain multiple lines of text in xml format.
I see the writeline activity - so far so good, i could get the string in a loop and use the writeline activity.
but i do not see a way to create a file that would allow this.
I need some examples or advice on the best way to create a file and write data to it in an ascii format.
Jeff
-
I actually am going to start working on tool in workflow for our survey teams that will export ascii files of monument data. I will post an example once I have completed something. What I was planning on doing is creating a csv file originally and then using a c# script activity to convert the file type to .asc before it is available for download.
0 -
here is my sample code to open a file and write to it and then later come back to it and append some more text. This is a good start on what I want to do.
insert this into the script part of the c# script activity:
string path = @"c:\tmp\MyTest.txt";
// This text is added only once to the file.
if (!File.Exists(path))
{
// Create a file to write to.
string createText = "Hello and Welcome" + Environment.NewLine;
System.IO.File.WriteAllText(path, createText);
}// This text is always added, making the file longer over time
// if it is not deleted.
string appendText = "This is extra text" + Environment.NewLine;
System.IO.File.AppendAllText(path, appendText);System.Windows.MessageBox.Show("Got here!");
I hope this help anyone who wants to know how to open a file and write to it from a workflow.
J
0 -
Thanks for posting this Nick! Saved me a bunch of time.
0
Please sign in to leave a comment.
Comments
3 comments