簡體   English   中英

.NET 標准 2.0 - Windows 注冊表 - 適用於 Mac OS X - Unity

[英].NET Standard 2.0 - Windows Registry - works on Mac OS X - Unity

I have my project (originally developed on Unity - Windows) on API Compatibility Level set to .NET Standard 2.0, and in my project I have an external.dll class library compiled also as .NET Standard 2.0 in which is used Microsoft.Win32. 我正在將一些數據保存到 Windows 注冊表中。

現在我也在調整項目以在 Mac 上工作,我發現我的 external.dll 與注冊表的東西在我的 Mac 上也沒有錯誤。

我一直在試圖找到這些數據可以存儲在哪里,因為 Mac 的 OS X 沒有像 Registry 這樣的 Windows?

為什么以及如何工作?

該代碼在 Unity 中用作 a.dll 插件。

using Microsoft.Win32;

...

    private RegistryKey key;

    public StorageImpl()
    {
        key = Registry.CurrentUser.OpenSubKey(RegistryKeyPath, true);

        if (key == null)
        {
            key = Registry.CurrentUser.CreateSubKey(RegistryKeyPath);
        }
    }

    public DateTime? StartDate
    {
        get
        {
            object value = key.GetValue(RegistryStartDate);
            return value != null ? DateTime.FromBinary((long)value) : (DateTime?)null;
        }

        set
        {
            if (value != null)
            {
                key.SetValue(RegistryStartDate, value.Value.ToBinary(), RegistryValueKind.QWord);
            }
            else
            {
                key.DeleteValue(RegistryStartDate);
            }

            key.Flush();
        }
    }

我找到了數據的保存位置: /Users/user/.mono/registry/CurrentUser/software/nameOfSoftware/values.xml

我不得不使用終端手動搜索列出所有文件夾內容: ls -a

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM