2

c#wpfアプリケーションを使用して、フォルダーを作成し、そのフォルダーにいくつかの画像をコピーしようとしています。

            curName = txt_PoemName.Text;
            // Specify a "currently active folder" 
            string activeDir = @"C:\Program Files\Default Company Name\Setup2\Poems";

            //Create a new subfolder under the current active folder 
            string newPath = System.IO.Path.Combine(activeDir, curName);

            // Create the subfolder
            System.IO.Directory.CreateDirectory(newPath);

                foreach(DictionaryEntry entry in curPoem){
                    string newFilePath = System.IO.Path.Combine(newPath, entry.Key.ToString() + Path.GetExtension(entry.Value.ToString()));
                    System.IO.File.Copy(entry.Value.ToString(), newFilePath, true);
                }

フォルダと画像を正常に作成しました。また、アプリケーションを介してそれらにアクセスできます。しかし、ローカルディスク上の場所にそれらが表示されません。マシンを再起動すると、アプリケーションもそれらを見ることができません。どうすればこれを解決できますか?

4

1 に答える 1

1

UACデータリダイレクトに遭遇したようです http://blogs.windows.com/windows/b/developers/archive/2009/08/04/user-account-control-data-redirection.aspx

アプリケーションを管理者として強制的に実行する必要があります。 .NETアプリケーションを管理者として強制的に実行するにはどうすればよいですか?

または、機密領域にデータを保存しないでください。のサブフォルダに保存することをお勧めします

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
于 2012-10-28T04:51:21.597 に答える