- Home /
              This question was 
             closed Mar 27, 2019 at 12:38 AM by 
             TheLuigiplayer for the following reason: 
             
 
            Die Frage ist beantwortet, die korrekte Antwort wurde akzeptiert
 
               Question by 
               TheLuigiplayer · Mar 26, 2019 at 03:20 PM · 
                c#unityeditorscreenshotscreencapture  
              
 
              How to correctly save a screenshot in a custom path?
Hello Unity-Community. I have a problem with my function, which should save a screenshot to a desired path:
     public void TakeScreenshot()
     {
         string folderPath = "Screenshots/";
 
         if (!System.IO.Directory.Exists(folderPath))
             System.IO.Directory.CreateDirectory(folderPath);
 
         var screenshotName = 
                                 "Screenshot_" + 
                                 System.DateTime.Now.ToString("dd-MM-yyyy-HH-mm-ss") + 
                                 ".png";
         ScreenCapture.CaptureScreenshot(System.IO.Path.Combine(folderPath, screenshotName));
         Debug.Log(folderPath + screenshotName);
     }
Although it perfectly works fine when using inside the Editor, it doesn't work when I export my project. The Screenshots folder is going to be created at the desired place, but the screenshots won't be saved. If I take the folderPath out of the Screen Capture Process, the screenshot will be created but inside of the "Data" Folder. What can I do?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by TheLuigiplayer · Mar 27, 2019 at 12:37 AM
Solved: Simply had to edit the folderPath to:
 string folderPath = Directory.GetCurrentDirectory() + "/Screenshots/";
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                