Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Create File & Get the scene path  (Read 2626 times)

0 Members and 1 Guest are viewing this topic.

serdar

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • View Profile
    • serdar
Create File & Get the scene path
« on: August 01, 2010, 03:02:53 PM »

Hello,

i want to create a text file under the game's installed folder. How can i get the path of the game folder?
I want to do this to save some values to use later. I now the Game.RegWriteString method but my text can be longer. I do not want to put a big string in registry.

if i write to a direct path it works well
var myFile = new File("c:\my.txt");
myFile.OpenAsText(2);
myFile.WriteLine("test");
myFile.Close();

i can not save to a file if it is in scenes folder.
var myFile = new File("scenes\Room\my.txt");
myFile.OpenAsText(2);
myFile.WriteLine("test");
myFile.Close();

how can i achive this? What is the best way to save long strings?

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Create File & Get the scene path
« Reply #1 on: August 01, 2010, 03:24:25 PM »

You should NOT create files in the game directory. Simply because there is a big chance it will not work. If your users install the game to "Program Files", and they're on Windows Vista or Windows 7 with UAC enabled (which is a common scenario), they will not have write access to that directory. If you really need to create files, you can use the directory WME uses for storing saved games. It can be queried using Game.SaveDirectory and it's guaranteed to be writeable.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

serdar

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • View Profile
    • serdar
Re: Create File & Get the scene path
« Reply #2 on: August 01, 2010, 04:12:27 PM »

Ok i see the problem. thank you for the reply.

Is "Game.RegWriteString" ok with the UAC?

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Create File & Get the scene path
« Reply #3 on: August 01, 2010, 04:22:27 PM »

Yes, the registry functions are safe to use.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.044 seconds with 20 queries.