- Home /
Where should I store text files I intend to edit?
Okay, so I have some xml documents (stored as txt cause I heard mobile has trouble with xml, but that's a different question) that I intend to access and edit at runtime. I've learned that you can't write to files in the resources folder, so that leaves me with a kinda dumb question: where should I put these files? I know that I should (probably) access them using Application.PersistantDataPath, but I wonder if I need to set up the folder before exporting. Or do I just need to do something along the lines of
 WhateverTheLoadFunctionIs(Application.PersistantDataPath + filename + ".txt") ;
 WhateverTheSaveFunctionIs(Application.PersistantDataPath + filename + ".txt", editedFile);
Follow up: would this require any changes across platforms?
Answer by ExtinctSpecie · Mar 11, 2017 at 08:12 PM
 yes you can use it as u stated although its different from pc to mobile 
         
  folderPath = (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer ? Application.persistentDataPath : Application.dataPath)+"/myDataFolder/";
 
 
 filePath = folderPath  + fileName + ".txt";
 
 if (!Directory.Exists (folderPath)) {
                 Directory.CreateDirectory (folderPath);    
             }
 
             File.WriteAllText(filePath, "hello world");   
     
             string readText = File.ReadAllText(filePath);
     
             string appendText = "This is extra text" ;
     
             File.AppendAllText(filePath, appendText);
     
     
     
     
 
 
 
Your answer
 
 
             Follow this Question
Related Questions
Duplicate an XML Document (with a different name) 0 Answers
A node in a childnode? 1 Answer
Load file on Android 1 Answer
Confusion with process of XML setup 0 Answers
Reading level specific file in build (from another level) 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                