Application Data文件夹和公司名称用下划线 [英] Application Data Folder and Company Name With Underscores

查看:181
本文介绍了Application Data文件夹和公司名称用下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的VB.NET 2008,.NET 3.5的应用程序使用定义为用户设置一个app.config。正如预期的那样,它创建的文件夹:

My VB.NET 2008, .NET 3.5 application is using an app.config with settings defined as User. As expected, it created the folder:

C:\Documents and Settings\<user>\Local Settings\Application Data\<company name>\

在此文件夹中的子文件夹的应用程序存储用户设置。然而,该公司名称的文件夹下有下划线:

In this folder are the sub-folders for the application to store the user settings. However, the folder of the company name has underscores:

C:\Documents and Settings\<user>\Local Settings\Application Data\This__Is_My_Company\

无此目录中的其他文件夹中有下划线,并且它看起来愚蠢。有没有办法告诉应用程序创建的文件夹没有在名称中下划线?

None of the other folders in this directory have underscores, and it looks stupid. Is there any way to tell the application to create the folder without underscores in the name?

更新(26-MAR-2012):

这似乎是更大的问题在Windows 7(至少 - 可能是XP的太多,但我已经关闭XP)。如果我使用.NET Framework创建的文件夹,如果它不存在......

This appears to be more of an issue on Windows 7 (at least - could be XP too but I'm already off XP). If I use the .NET Framework to create the folder if it doesn't exist ...

Const TEST_FOLDER_PATH As String = "{0}\{1}"

Dim appDataFolderPath As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Dim companyName As String = My.Application.Info.CompanyName

MessageBox.Show(String.Format(TEST_FOLDER_PATH, appDataFolderPath, companyName))

......然后它会产生一个文件夹路径无公司名称突出。奇怪的是,.NET 3.5仍然为用户的app.config设置创建自己的\应用程序数据\本地\文件夹中的下划线。

... then it will produce a folder path without underscores in the company name. Oddly enough, .NET 3.5 still creates its own folder in \AppData\Local\ for the user's app.config settings with underscores.

我结束了一个文件夹用下划线为用户的app.config数据,一个文件夹,而不强调这样我就可以告诉我们的第三方拼写检查程序在何处存储用户dictionary.txt文件。看来我得硬$ C C公司名称$以保持一切一个文件夹,或生活在两个文件夹。精彩......

I end up with one folder with underscores for the user's app.config data, and one folder without underscores so I can tell our third-party spell checker where to store the user-dictionary.txt file. Looks like I'll have to hard-code the company name in order to keep everything to one folder, or live with two folders. Wonderful ...

推荐答案

的的 LocalFileSettingsProvider 类是用于存储配置设置在.NET中负责任的默认。这似乎是摆在下划线为所有托管应用程序在默认情况下 - 我看到它在几个应用程序在我的本地设置目录。如果你真的关心这个名字,你可以:

The LocalFileSettingsProvider class is responsible by default for storing config settings in .NET. It seems to put in underscores for all managed applications by default - I see it in several apps in my local settings directory. If you are really concerned about the name, you could:

  1. 使用的<一个描述的技术href="http://stackoverflow.com/questions/439538/changing-the-net-application-configuration-file-name">Changing在.NET应用程序配置文件名的问题。
  2. 创建你自己的SettingsProvider,并将它使用正确的文件名。这听起来像重新发明轮子,但。
  3. 使用骆驼情况为您的公司名称。
  1. Use the technique described in Changing the .NET application configuration file name question.
  2. Create your own SettingsProvider and have it use the right filename. This sounds like re-inventing the wheel though.
  3. Use camel-case for your company name.

这篇关于Application Data文件夹和公司名称用下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆