Save xml log file in MAC

Dani_S 4,501 Reputation points
2024-05-29T10:31:16.86+00:00

Hi,

In windows I keep in c drive in MAC where i save my log file?

Thanks,

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2024-06-03T03:44:54.7666667+00:00

    Hello,

    i want path outside the application.

    The Maccatalyst app complies with Application Sandbox rules from Apple. In terms of the file system, your application is limited to creating and deleting files and directories in its home directory. Therefore, you cannot access folders outside of your app.

    Please refer to the following code to visit the Document /Library folder:

                var path = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), localFileName);// document folder
                var localpath = Path.Combine(FileSystem.AppDataDirectory, localFileName);//library folder
     
                File.WriteAllText(path, CurrentContents);
    

    For more details, please see File system helpers - .NET MAUI | Microsoft Learn

    FileSystem.AppDataDirectory Returns the Library directory that is backed up by iTunes and iCloud.

    And File system access in Xamarin.iOS - Xamarin | Microsoft Learn (This doc is about Xamain.iOS, it applies to MAUI Maccatalyst)

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,161 Reputation points Volunteer Moderator
    2024-05-29T16:12:21.4433333+00:00

    application data files belong under "~/Library/Application Support/<app-name>". though some still use "~/Library/<appname>". macOs also has a standardized logging system via the Logger() api.

    https://developer.apple.com/documentation/os/logger


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.