2 Replies - 607 Views - Last Post: 10 January 2012 - 03:43 PM Rate Topic: -----

#1 eric_the_scot   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-January 12

writing a int array to file for high score

Posted 05 January 2012 - 05:26 AM

hello i am trying to store the score array to a file so that the scores can be kept even while the game is closed but it dosent seem to like the brackets around where i want to store the file, and it says this about the score array

'GameStateManagement.GameOptions.score' is a 'field' but is used like a 'type' C:\Users\Eric Sutherland\Documents\ICGGS game\ICGGSAssignment2011\ICGGSAssignment2011\ICGGSAssignment\GameOptions.cs


        public static int[] score = new int[5];
        public static int[] level = new int[5];
        public static Boolean active = false;
        System.IO.File (@"C:\Users\Eric Sutherland\Documents\ICGGS game\
        ICGGSAssignment2011\ICGGSAssignment2011/Score.txt",score);



i am rather new at programming so i may be doing this completly wrong altogether,

thankyou for any advice

Is This A Good Question/Topic? 0
  • +

Replies To: writing a int array to file for high score

#2 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: writing a int array to file for high score

Posted 05 January 2012 - 06:04 AM

Please post the rest of your code.
Was This Post Helpful? 0
  • +
  • -

#3 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: writing a int array to file for high score

Posted 10 January 2012 - 03:43 PM

        System.IO.File (@"C:\Users\Eric Sutherland\Documents\ICGGS game\
        ICGGSAssignment2011\ICGGSAssignment2011/Score.txt",score);



I'm unclear what you're trying to accomplish here. System.IO.File is a type, not a method. To write your scores to a file you typically need to create a StreamWriter object and write the file using that. Take a look at this article on MSDN on the File class. There is an example at the bottom on checking if a file exists. You would also be better off to use a relative path compared to the absolute path like you are trying to use.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1