How do i get the file path off my emulator for a folder on my device?

Ali, Bilal (Student) 1 Reputation point
2021-03-12T21:25:04.523+00:00

The folder and file is on the emulator and i dont know how to get the path. Can someone help. Thanks in advance

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-03-15T07:30:21.467+00:00

    Hello,

    Welcome to Microsoft Q&A!

    We can simply use System.Environment.GetFolderPath() to access the file path on each platform .

    Sample code
       public string GetPath()  
       {  
           var path= Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "count.txt");  
         
           if (backingFile == null || !File.Exists(backingFile))  
           {  
               return ;  
           }  
           return path;  
       }  
    

    Check the exact directories path on each platform

    iOS Application directories

    Android internal storage


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments