首页 \ 问答 \ 存储自定义配置文件的位置(Where to store custom configuration files)

存储自定义配置文件的位置(Where to store custom configuration files)

我目前在应用程序目录中存储了一个序列化的XML文件,其中包含特定于程序操作的所有更改(不是典型的系统或用户配置)。 几周前,我们开始遇到无法正确保存的问题 (请阅读我之前关于此的问题 )。

简而言之,我们终于发现Windows 7(有时是Vista)在写入应用程序目录(特别是Program Files下的任何内容)时存在问题。 现在,如果这是一个普通的配置文件,我只需将它存储在用户的APPDATA文件夹下,但这不正常。 我们在自己的仪器上运行它,并且错误配置是客户在运行我们的软件时遇到问题的99%。 因此,我们需要访问此文件,以便他们可以轻松找到并通过电子邮件发送给我们。 Appdata对于有经验的用户来说很难找到,更不用说非技术人员了。

我们还尝试以管理员身份运行它,并使文件夹权限全开(我们可以控制它运行的每台计算机;它永远不会在某个随机人员的计算机上运行)。 但是,这些有时是有效的,有时则不然。

最糟糕的是,当我把文件写回来时,它甚至不会抛出错误; 它只是将它写入某个临时目录,该目录在某个未知的时间点到期。 几周后,我们的用户将遇到问题,配置文件全部搞砸了。

所以,我的问题是我应该在哪里存储这个文件,如果不是在Program Files中? 我是否应该把它放在APPDATA中,并制作一个小工具,以便在出现问题时自动通过电子邮件发送给我们? 或者我可以将其保留在Program Files中,但是更改某些特定权限或注册表项以使其正常运行?


I currently store a serialized XML file in the application directory that contains all changes specific to the program operation (not typical system or user configuration). Weeks ago, we started running into problems where it would not save correctly (read my previous question about this).

Long story short, we finally discovered that Windows 7 (and sometimes Vista) has an issue with writing into the application directory (specifically anything under Program Files). Now, if this were a normal configuration file I would simply store it under the user's APPDATA folder, but it is not normal. We run this on our own instrumentation, and misconfigurations are 99% of the reason customers have issues running our software. So we need this file to be accessible such that they can easily find it and email it to us. Appdata is hard enough for experienced users to find, much less very non-technological people.

We've also tried running it as Administrator, and making folder permissions wide open (we have control over every computer it runs on; it will never run on some random person's machine). But, these sometimes work, and sometimes do not.

The worst part is that when I write the file back out, it doesn't even throw an error; it simply writes it to some temporary directory that expires at some unknown point in time. Weeks later, our user will have an issue, and the configuration file is all messed up.

So, my question is where should I be storing this file, if not in Program Files? Should I just put it in APPDATA anyway, and make a small utility that emails it to us automatically in case of a problem? Or can I leave it in Program Files, but change some specific permission or registry key to allow it to operate normally?


原文:https://stackoverflow.com/questions/3267960
更新时间:2021-07-17 10:07

最满意答案

当你试图找到gmap的视图(你的做法正确),之后你会立即尝试获取带有函数的地图get map() (这里你做错了)就行了下一步你的获取null onCreate方法

gmap=((MapFragment)getFragmentManager().findFragmentById(R.id.map));
 gmap.getMap();

当你找到你的东西的视图时,永远不要使用方法(getMap()或熟悉的东西)!


ok do the next your getting null onCreate method when your trying to find view of gmap(your doing right) and after which your trying straight away to get a map with function get map()(here your doing wrong) just do the next

gmap=((MapFragment)getFragmentManager().findFragmentById(R.id.map));
 gmap.getMap();

never use a method (getMap(),or something familiar) when your finding the View of your thing!

相关问答

更多
  • 是的,捕获任何RuntimeException几乎总是一个代码气味。 C2维基似乎同意。 一个例外可能是一些特别防御性的代码,从其他模块运行相当多的随机代码。 这种防御结构的例子将是EDT ,ThreadPools / Executors和插件系统。 Yes, catching any RuntimeException is almost always a code smell. The C2 Wiki seems to agree. An exception would probably be some ...
  • 问题发生在您在sendSms方法开始时创建PendingIntent对象的sendSms 。 你正在实施SendSMS作为一项活动,但我认为它不是必须的,并且它没有被正确初始化为一个活动,所以你看到了这个失败。 从你的sendingms类中取出extends Activity ,并将sendSms方法更改为如下启动: public class SendSms { public void sendSMS(Context context, String phoneNumber, String mess ...
  • 我怀疑,您已将菜单声明为实例变量(位于类的顶部),但您从未将其实例化为局部变量。 添加行 menu = (ImageView)findViewById(R.id.menu) 在onCreate()方法的顶部,在设置OnClickListener之前,它将起作用。 声明实例变量(您已经完成)和实际初始化它之间存在差异。 从这个意义上讲,您可以像常规java类中的构造函数一样查看onCreate()方法。 将变量声明在类的顶部是不够的,您必须将其初始化为实际对象的变量。 这可能听起来微不足道,但相信我并非如 ...
  • 你可以从消除NULL的源头开始: 更改 if (error) { return NULL; } 成 if (error) { return DefaultObject; // Ex: an empty vector } 如果返回默认对象不适用,并且您的代码库已经使用异常,请执行 if (error) { throw BadThingHappenedException; } 然后,在适当的地方添加处理。 如果你正在使用遗留代码,你可以创建一些包装函数/类: ResultType ...
  • 您的txtname和txtnumber为空 即 final EditText txtname=(EditText)findViewById(R.id.editText1); final EditText txtnumber=(EditText)findViewById(R.id.editText2); 当您尝试访问空引用时,您将获得NullPointerException 试着让他们这样 final EditText txtname=(EditText)v.findViewById(R.id.editT ...
  • 当你试图找到gmap的视图(你的做法正确),之后你会立即尝试获取带有函数的地图get map() (这里你做错了)就行了下一步你的获取null onCreate方法 gmap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)); gmap.getMap(); 当你找到你的东西的视图时,永远不要使用方法(getMap()或熟悉的东西)! ok do the next your getting null onCreate method ...
  • 这一行在这里 btnSongList.setOnClickListener(new OnClickListener(){@Override public void onClick(View v) {visible();}}); 您从未为此特定视图调用findViewById() ,因此指针仍为null。 This line here btnSongList.setOnClickListener(new OnClickListener(){@Override public void on ...
  • 以下是我如何运作的: 在XML文件(我的main.xml)中使用扩展类规范 在你的活动课上: setContentView(R.layout.main); Vor ...
  • 正如@iagreen所说,“具体来说,你从你的适配器的getView方法返回null”。 我在某些情况下在getWiew中的自定义适配器中返回null。 As @iagreen said, "Specifically, you are returning null from your getView method of your Adapter". I was returning null in some case in custom adapter in getWiew.
  • 你宣布了GPSTracker gps; 在你的AsyncTask中,它似乎永远不会被初始化。 换句话说,它是空的。 因此, NullPointerException 。 我想你需要一个AsyncTask的构造函数来设置它: public PostData (GPSTracker gps) { this.gps = gps; } 然后在MainActivity new PostData(gps).execute(); AsyncTask只是一个类,与成员变量一样,需要设置,如果你想使用它们。 Yo ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)