2

i am trying to create a folder and copy some images into it using c# wpf application.

            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);
                }

i have successfully created the folder and images. and also i can access them via application. but i cant see them in the location on my local disk. when i restart the machine , then application also cant see them.how can i solve this?

DocMax
  • 12,094
  • 7
  • 44
  • 44
Hashan
  • 185
  • 2
  • 2
  • 8

1 Answers1

1

Sounds like you have encountered UAC Data Redirection http://blogs.windows.com/windows/b/developers/archive/2009/08/04/user-account-control-data-redirection.aspx

You need to either force the application to run as an administrator. How do I force my .NET application to run as administrator?

Or not save your data in a sensitive area. I would recommend saving in a subfolder of

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
Community
  • 1
  • 1
Alex Wiese
  • 8,142
  • 6
  • 42
  • 71