- Home /
Question by
Anagashi · Nov 09, 2015 at 11:12 AM ·
screenshotreadpixelssave-to-file
How to save screenshot to a folder? (standalone player) (Window)
Greeting,
I am trying to screenshot the game by using ReadPixels methods, and it works, but it seems that no matter how I tried to save it inside a folder that share with the some location with the game. It failed.
Here are my code:
string folderPath = "C:/screenshots/";
string fileName = "filename";
// Create the folder beforehand if not exists
if(!System.IO.Directory.Exists(folderPath))
System.IO.Directory.CreateDirectory(folderPath);
// save our test image (could also upload to WWW)
File.WriteAllBytes(Application.dataPath + "/../Photo-" + count + ".jpg", bytes);
Please help me solve this issues
Thanks.
Comment
Try it with back slashes -> File.WriteAllBytes(Application.dataPath + "\\..\\Photo-" + count + ".jpg", bytes);
Answer by hoffmanuel · Nov 09, 2015 at 11:37 AM
Try
DirectoryInfo dInfo = new DirectoryInfo(Application.dataPath);
File.WriteAllBytes(dInfo.Parent.FullName + "\\Photo-" + count + ".jpg", bytes);
Your answer
