none
File.Writeline Arguments RRS feed

  • Question

  • There is some inaccuracy in the File.Writeline arguments.  In it's description it states only 2 arguments (filePath, lineNumber). But when I put in those in the program, it gives me an error saying"Method 'File.WriteLine' is supplied 2 arguments, but takes 3 arguments" I was hoping to have some clarification on what those 3 arguments are.

    -Gizmologist
    • Edited by Gizmologist Monday, November 17, 2008 12:59 AM
    Sunday, November 16, 2008 11:22 PM

Answers

  • This works,

    make sure you have a file at the location, or it will FAIL

    and be sure the line number you call is in the file too.

    Path = "C:\" 
     
    String = "Hello World" 
     
    IsThisSuccessful = File.WriteLine(Path + "Data.txt", 1, String)  
    TextWindow.WriteLine("2 " + IsThisSuccessful) 

     

    • Edited by Rushworks Monday, November 17, 2008 3:14 AM
    • Proposed as answer by Rushworks Monday, November 17, 2008 3:14 AM
    • Marked as answer by Vijaye RajiModerator Monday, November 17, 2008 4:18 AM
    Monday, November 17, 2008 3:13 AM

All replies

  • It asks for file Path and line Number, so I'm guessing the 3rd argument might be what to write, so you'd have something like

    File.WriteLine("C:\Test.txt", 2, "This was written")

    Perhaps. I'm shooting in the dark here.

    -tested-

    And failed :(.
    • Edited by Pacolaco Monday, November 17, 2008 2:25 AM
    Monday, November 17, 2008 2:21 AM
  • This works,

    make sure you have a file at the location, or it will FAIL

    and be sure the line number you call is in the file too.

    Path = "C:\" 
     
    String = "Hello World" 
     
    IsThisSuccessful = File.WriteLine(Path + "Data.txt", 1, String)  
    TextWindow.WriteLine("2 " + IsThisSuccessful) 

     

    • Edited by Rushworks Monday, November 17, 2008 3:14 AM
    • Proposed as answer by Rushworks Monday, November 17, 2008 3:14 AM
    • Marked as answer by Vijaye RajiModerator Monday, November 17, 2008 4:18 AM
    Monday, November 17, 2008 3:13 AM
  • Ohaw.

    You can shorten it.

    IsThisSuccessful = File.WriteLine("C:\Data.txt", 1, "Puhpuhpuh")   
    TextWindow.WriteLine("2 " + IsThisSuccessful)  

    Wonderful.

    Ridiculous RPG + Save system INCOMING!... In a while..
    • Edited by Pacolaco Monday, November 17, 2008 3:25 AM
    Monday, November 17, 2008 3:24 AM
  • Apologies for the confusion.
     
    The File APIs are being revamped and made more powerful.  You can get a full fledged File object for the next release.
    Monday, November 17, 2008 4:19 AM
    Moderator
  • Thanks for the clarification, I to also encountered confusion over this. 
    Tuesday, November 18, 2008 3:15 PM