C# 创建文件夹并将文件集复制到本地磁盘
我正在尝试创建一个文件夹,并使用c#wpf应用程序将一些图像复制到其中C# 创建文件夹并将文件集复制到本地磁盘,c#,wpf,file,file-io,directory,C#,Wpf,File,File Io,Directory,我正在尝试创建一个文件夹,并使用c#wpf应用程序将一些图像复制到其中 curName = txt_PoemName.Text; // Specify a "currently active folder" string activeDir = @"C:\Program Files\Default Company Name\Setup2\Poems"; //Create a new subfold
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);
}
我已成功创建文件夹和图像。我还可以通过应用程序访问它们。但是我在本地磁盘上的位置看不到它们。当我重新启动机器时,应用程序也看不到它们。我如何解决这个问题 听起来您遇到了UAC数据重定向 您需要强制应用程序以管理员身份运行。 或者不将数据保存在敏感区域。我建议保存在的子文件夹中
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);