Zum Hauptinhalt gehen

create file and write ascii lines to it - help

Kommentare

3 Kommentare

  • Permanently deleted user

    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
  • Permanently deleted user

    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
  • Permanently deleted user

    Thanks for posting this Nick!  Saved me a bunch of time.

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.