好吧,我不知道如何输入这一切,所以请耐心等待.
这超出了我,我仍然是C#的新手.我基本上需要在运行程序的当前用户的漫游应用程序数据中创建一个文件夹.我还需要访问应用程序数据部分中的另一个文件夹,然后用我创建的应用程序数据文件夹中的文件副本替换文件.
Ste*_*eve 40
前两次通过很简单
// The folder for the roaming current user
string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
// Combine the base folder with your specific folder....
string specificFolder = Path.Combine(folder, "YourSpecificFolder");
// CreateDirectory will check if folder exists and, if not, create it.
// If folder exists then CreateDirectory will do nothing.
Directory.CreateDirectory(specificFolder);
Run Code Online (Sandbox Code Playgroud)
在最后一次传递中不清楚您要复制文件的位置.
但是,假设您有一个名为的文件
string file = @"C:\program files\myapp\file.txt";
File.Copy(file, Path.Combine(specificFolder, Path.GetFileName(file));
Run Code Online (Sandbox Code Playgroud)
MSDN链接:
Path类
Environment.SpecialFolder枚举
File.Copy方法
| 归档时间: |
|
| 查看次数: |
27868 次 |
| 最近记录: |