File.Move() on Android doesn't seem to work.
I've been trying to figure out how to move a screenshot from the install directory on android to the DCIM folder on either the phone storage or the SDcard storage.
Here's what's working:
- Application.CaptureScreenshot(); Saves is in Android/data/identifier-bundle/files/
- Detect platform to know which dataPath to search.
- If(File.Exists); Using Application.persistentDataPath
Here's what's not working:
- File.Move()
// Code bit. string tempPath = ""; if (Application.platform == RuntimePlatform.Android) { tempPath = Application.persistentDataPath + "/" + tempName; }
if (Application.platform == RuntimePlatform.WindowsEditor)
{
tempPath = tempName;
}
if (File.Exists(tempPath))
{
if (Application.platform == RuntimePlatform.Android)
{
string savePath = "/storage/extSdCard/DCIM/TMP Screenshots/";
try
{
File.Move(tempPath, savePath);
} catch (IOException e)
{
// Open the ui again to show it didn't move.
uilayer.open = true;
}
}
if (Application.platform == RuntimePlatform.WindowsEditor)
{
Debug.Log("Screenshot saved! Find it at " + tempPath);
}
needScreenShot = false;
uilayer.blockSwipes = false;
takeScreenshotButton.interactable = true;
saved = true;
}
I've also tried to check for directory and create, but that doesn't work either.
I know there's a plugin that takes care of all of this for me, but I want to code it for myself. It's part of my learning goals.
Your answer
Follow this Question
Related Questions
Big scene weight in apk 1 Answer
How to duplicate a file and save it in a new folder? 0 Answers
How Do You Get Google Cardboard to Read a Continuous Press? 0 Answers
APK file size too big! 1 Answer
Daydream App Crashes on starting 1 Answer