【问题标题】:create folder and copy set of files to local disk创建文件夹并将文件集复制到本地磁盘
【发布时间】:2012-10-17 20:52:30
【问题描述】:

我正在尝试使用 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);
                }

我已成功创建文件夹和图像。我也可以通过应用程序访问它们。但我在本地磁盘上的位置看不到它们。当我重新启动机器时,应用程序也看不到它们。我该如何解决这个问题?

【问题讨论】:

    标签: c# wpf file file-io directory


    【解决方案1】:

    听起来你遇到了 UAC 数据重定向 http://blogs.windows.com/windows/b/developers/archive/2009/08/04/user-account-control-data-redirection.aspx

    您需要强制应用程序以管理员身份运行。 How do I force my .NET application to run as administrator?

    或者不要将您的数据保存在敏感区域。我建议保存在

    的子文件夹中
    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多