3

generate folderWindowsがどこにインストールされるかを知りたいClickOnce applicationです。

スタートメニューには、ファイルへの「ショートカット」があり、次のような「startrek」フォルダーに入れられます。

C:\Users\USERNAME\AppData\Local\Apps\2.0\GT??4KXX.PRJ\EGV???1G.??C\prin..tion_7???5a2?????74b6_0000.0002_1dae?? ??89111c35

これらのフォルダ名は何を意味しますか?


例えば:

たとえばsettings.txt、ユーザーがアプリケーションのいくつかのパラメーターを変更できるようにしたいファイルがある場合。どこにインストールされ、どこにファイルがあるかを知る方法はありますか? (ユーザーがこの settings.txt ファイルを見つける場所)。

たとえば、C:\ にファイルを作成できることを知っています。アプリケーションを起動した後、「強力な」パスでファイルを変更します。しかし、C:\ にあるファイルやフォルダーが多すぎるのは好きではなく、アプリケーションと同じフォルダーに設定ファイルを配置することを好みます。しかし、ClickOnce のインストールでは、そのファイルを見つけるのは非常に困難です (不可能です)。

「startrek」がプロジェクトのハッシュのようなものである場合のようです。


だから私はフォルダが何を意味するのか、それがプロジェクトのハッシュなのか、それが何なのかを知りたいです。

4

3 に答える 3

5

To find the folder that contains your executable, you can use the Assembly.Location property.

For example:

string exeFolder = System.Reflection.Assembly.GetExecutingAssembly().Location;

However, if you want to store settings for your ClickOnce app, you shouldn't do it by writing a file to the .exe's folder.

Instead, you should use Microsoft's Application Settings support. Doing it any other way is going to be a lot of extra hassle, and Microsoft's support is very good. It does need half an hour to read through the documentation, but it's far and away the best thing to do, IMHO.

(I'm assuming that you only need the settings to be stored on the local PC for the same user to use later. If you want the settings to follow the user around (i.e. roaming settings), you can't use the Microsoft support.)

If you have more complex settings that you want to store in a file that you create directly, you should consider using the isolated storage that the answer from JRoughan mentions.

于 2013-03-28T19:30:03.317 に答える
4

ClickOnce アプリ内から、ファイルが保存されている既定のディレクトリを見つけることができます。

ApplicationDeployment.CurrentDeployment.DataDirectory

または、分離ストレージを使用して、アプリケーションごとに保存するか、ユーザーごとに保存するかを選択できます。

アプリ自体の外部からこれらのフォルダーを特定することはできないと思います。既知の場所が必要な場合は、ハードコードする必要があります。

アップデート

また、アプリのインストール ディレクトリがどうなるかを推測できるとは思えません。アプリの更新が同じ場所にないため、可能であっても使用するのは賢明ではありません。

于 2013-03-28T19:14:18.007 に答える