Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
iPhone System.IO.File.Exists() not working

The following instruction checks if the file at path exists:

string path = GetiPhoneDocumentsPath();
if (System.IO.File.Exists(path) == false) XmlTextWriter textWriter = new XmlTextWriter(path,null);

Then if the file does not exists it creates a new one, it all works well in unity execution, but when I execute the program in iphone, the file is never created.

Here's the function to obtain the path:

public static string GetiPhoneDocumentsPath()
{
    // Your game has read+write access to /var/mobile/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Documents 
    // Application.dataPath returns              
    // /var/mobile/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/myappname.app/Data 
    // Strip "/Data" from path 
    string path = Application.dataPath.Substring(0, Application.dataPath.Length - 5);
    // Strip application name 
    path = path.Substring(0, path.LastIndexOf('/'));
    return path + "/Documents/myFile.xml";
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Got it!

FileInfo info = new FileInfo(path);
    if (info == null || info.Exists == false) { ... };
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!