Search Unity

Windows Phone File.Exists always returns false.

Discussion in 'Windows' started by sysameca, Jan 22, 2016.

  1. sysameca

    sysameca

    Joined:
    Mar 2, 2013
    Posts:
    99
    I am using UnityEngine.Windows in order to read and write files to a windows mobile device, however i am struggling to make File.Exist() work. Here is what I am doing:
    1. If the file exists - i use File.ReadAllBytes("Gamedata.dat") to read all bytes from it
    2. If the file does not exist - i use File.WriteAllBytes("Gamedata.dat") to create a new file

    However File.Exist("Gamedata.dat") always evaluates to false when i run it on a ARM device or emulator. What am I missing here?
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    Add path to file name. Application.persistentDataPath should be good for that.
     
  3. sysameca

    sysameca

    Joined:
    Mar 2, 2013
    Posts:
    99
    Great, it works with Application.persistentDataPath on the actual mobile device (Windows Phone 8.1). But it does not work on a Mobile Emulator - Universal Windows 10. Can I assume it should work properly there? I don't have any physical device to test this unfortunately..
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    It should work on physical device. Do you have a physical machine with Windows 10? You could try there on a desktop.
     
  5. sysameca

    sysameca

    Joined:
    Mar 2, 2013
    Posts:
    99
    Yes just tried it and it works on desktop. I will assume that it works for each device that uses Windows 10 platform. Thank you for your time.