简体   繁体   English

Windows Forms,Microsoft OneDrive 和设置。设置 class

[英]Windows Forms, Microsoft OneDrive and Settings.Settings class

I have a Windows forms application that uses Application settings using the .NET settings class. Typically I have a setting such as WindowXSize which is loaded when the program starts, and saved when it ends as follows:我有一个 Windows forms 应用程序,它使用应用程序设置,使用 .NET 设置 class。通常我有一个设置,例如 WindowXSize,它在程序启动时加载,并在程序结束时保存,如下所示:

 Properties.Settings.Default.WindowXSize = 400;
 Properties.Settings.Default.Save;

On load it is just the reverse.在加载时正好相反。 Now this works fine and I have thousands of users with no issues.现在这工作正常,我有成千上万的用户没有问题。 However, if someone has configured MicroSoft OneDrive to replicate their documents folder, the values never change even if the window is resized.但是,如果有人将 MicroSoft OneDrive 配置为复制其文档文件夹,则即使调整 window 的大小,这些值也永远不会改变。 Not only that, the software can also allow users to save various files in a folder of their choice.不仅如此,该软件还可以让用户将各种文件保存在他们选择的文件夹中。 Most of the time this is in the documents folder (or subfolder of it).大多数情况下,这是在文档文件夹(或其子文件夹)中。 To make sure I get the correct location of the Documents folder I have the following:为了确保我得到 Documents 文件夹的正确位置,我有以下内容:

 path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

This always returns the typical c:\users\userid\documents folder even if OneDrive is syncing the documents folder.这始终会返回典型的 c:\users\userid\documents 文件夹,即使 OneDrive 正在同步文档文件夹也是如此。 The user can then save the file and there are no errors.然后用户可以保存文件并且没有错误。 However, if the user then tries to load it, the file is not found.但是,如果用户随后尝试加载它,则找不到该文件。 So it would seem that OneDrive is completely ignoring the .NET mechanisms for Application settings and file IO. Is there any work around for this?因此,OneDrive 似乎完全忽略了应用程序设置和文件 IO 的 .NET 机制。是否有任何解决方法? Or am I doing something wrong?还是我做错了什么? Note that I refuse to load up OneDrive for my documents on my development machine so as to avoid all these issues as well as many others that exist.请注意,我拒绝在我的开发机器上为我的文档加载 OneDrive,以避免所有这些问题以及许多其他存在的问题。 Thanks, Tom谢谢,汤姆

Did you change the directory, where your application stores the user settings?您是否更改了应用程序存储用户设置的目录?

Default is: "User settings are saved in a file within a subfolder of the user's local hidden application data folder."默认值为:“用户设置保存在用户本地隐藏应用程序数据文件夹的子文件夹中的文件中。” 1 1个

Normally OneDrive does not synchronize this hidden AppData folder.通常 OneDrive 不会同步这个隐藏的 AppData 文件夹。 Therefore your question makes little sense.因此,您的问题毫无意义。 Please add more information.请添加更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM