# How to create temp folder to store a file from external directory and use it in a game

I would like to copy a 3D model from external library and save it in temp/Resources/StreamingAssets folder to instantiate an object in unity scene. 

public class FBXOBJLoader : MonoBehaviour {

string src;
// Use this for initialization
void Start () {
src = EditorUtility.OpenFilePanel("Select Model", "", "fbx");
//Output the Game data path to the console
Debug.Log("Path : " + src);
StartCoroutine("CopySomething");
}

IEnumerator CopySomething()
{
print("Start");
string path;
path = Application.temporaryCachePath;
FileUtil.CopyFileOrDirectory(src,path);
yield return null;
}
}


• Now it's storing in temp. does anybody know how to use it in unity scene? – Manoj Balaji M Nov 19 '18 at 9:56

The issue is that Application.temporaryCachePath returns the folder, you need the intended filepath. If you print it to the console it looks like this: C:/Users/MyName/AppData/Local/Temp/SomeCompanyName/SomeProjectName

Therefore, to fix the issue, change:

path = Application.temporaryCachePath;


To:

path = string.Concat(Application.temporaryCachePath, "/", Path.GetFileName(src));


Note, to use Path.GetFileName you must add using System.IO` to the top of your script.

• after that how can i instantiate an object into unity scene. consider my 3D model name is "flask". Now i selected the flask it not showing any error now can you please tell me how to use it – Manoj Balaji M Nov 19 '18 at 8:27
• That is a whole other question in itself. I suggest you accept the answer for this specific question if it solved your issue and ask a separate question about instantiating an FBX at runtime. – mr-matt Nov 19 '18 at 8:33
• it is a part of my question. Please check my title and content. i clearly asked - in title -> how to use it in game? - in message body -> temp/Resources/StreamingAssets folder to instantiate an object in unity scene. – Manoj Balaji M Nov 19 '18 at 8:44
• If you insist, then I suggest you have a search on google first. There is plenty of help available. – mr-matt Nov 19 '18 at 8:46
• Sorry mr-matt, I am requesting you. you are the person helping me here. i just want to show the 3d model from external folder to unity scene. for that i tried many ways but failed. now i am trying a new method to copy the selected 3d model to my application temp and try to use this. so only i raised this question. if my words hurt you i am really very very sorry for that. Hope i ll get help and Thanks – Manoj Balaji M Nov 19 '18 at 8:53