繁体   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