Navigation

    OpenIAP

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Write to txt file

    General Discussion
    openrpa text
    3
    3
    101
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Arshiya T last edited by

      How do I write something to a text file (and create the file if not already created) using OpenRPA? Also, how do I "append" or "overwrite" while writing in that text file?

      Allan Zimmermann 1 Reply Last reply Reply Quote 0
      • Allan Zimmermann
        Allan Zimmermann @Arshiya T last edited by Allan Zimmermann

        add an "invoke code" activity.
        lets assume you have a variable called stringcontent with the content you want to write or append to the file, then

        To overwrite a file use

        System.IO.File.WriteAllText("c:\myfile.txt", stringcontent)
        

        and to appened to an existing file

        System.IO.File.AppendAllText("c:\myfile.txt", stringcontent)
        

        To read more go here, and then expand the "methods" section in the side menu.
        For instance here you will also find Exists, to check if a file exists. You can use this in the expression part of an If acitvity, or inside invoke code

        System.IO.File.Exists("c:\myfile.txt")
        
        A 1 Reply Last reply Reply Quote 2
        • A
          artuser2255 @Allan Zimmermann last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • First post
            Last post