- Home /
How to copy Files external to Game application to Application.dataPath
I'm using a file browser dialogue in unities GUI to allow users to select a file and have it imported to Application.dataPath.
this gives the file path of the selected file ((Path.Combine(m_currentDirectory, m_files[m_selectedFile])))
when i click a buton the file at that path should be copied or moved to Application.dataPath.
I had tried File.Move but i had too many problem with it .
is it best to use File.Move or is there a better way ?
Answer by JChilton · Dec 09, 2013 at 07:58 PM
string filePath = ((Path.Combine(m_currentDirectory, m_files[m_selectedFile])));
string destinationPath = Application.persistentDataPath + "/whateverFolder/" + someFileName;
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
System.IO.File.WriteAllBytes(destinationPath,fileBytes);
='] thank you ! . I completely forgot about that method . this should be fine.
just one problem. Right now i'm denied access to destinationPath. thats just about the only issue.
Your answer
![](https://koobas.hobune.stream/wayback/20220613123816im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Where do my code files save for my project? 1 Answer
[File-explorer]How Implements a crude file browser in Unity3d? 0 Answers
How Do I Write to a Created File? 1 Answer