Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Cannot get the File Object to work  (Read 2556 times)

0 Members and 1 Guest are viewing this topic.

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Cannot get the File Object to work
« on: March 05, 2010, 02:00:49 PM »

I'm having some difficulties with this.

Code: [Select]
var proFile = new File("\saves\profiles.txt");
proFile.OpenAsText(1)

Whether "saves\profiles.txt" exists or not, the OpenAsText(1) returns false.

Hope someone can help me.
Logged

matthieuj

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 19
    • View Profile
Re: Cannot get the File Object to work
« Reply #1 on: March 05, 2010, 02:32:25 PM »

Maybe it's just a typo in your post but did you remove the backslash at the beginning when you call the file?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Cannot get the File Object to work
« Reply #2 on: March 05, 2010, 02:42:29 PM »

Yes, matthieuj has a good point. You're accessing a directory called "saves" in the root directory of current disk. That's proably not what you want. Use the Game.SaveDirectory property instead.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Cannot get the File Object to work
« Reply #3 on: March 05, 2010, 03:16:59 PM »

Okay, it was the thing with the "\saves\profiles.txt".

What got me was that Game.FileExists("\saves\profiles.txt") returned true. But it seems, that Game.FileExists will pretty much always return true  :o
Logged
 

Page created in 0.021 seconds with 20 queries.