如何将 文件D:\temp\001\1.xml 拷贝到 e:\myData\001\1.xml (需要同步创建e:\myData\001) 有这样的函数嘛 或者比较好的方法 ,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string sourceFileName = @"c:\a.txt"; string destFileName = @"c:\a\a\a.txt"; string destDir = Path.GetDirectoryName(destFileName); if (!Directory.Exists(destDir)) { Directory.CreateDirectory(destDir); } File.Copy(sourceFileName, destFileName); 自己定义一个吧 private void CopyFile(){string SourcePath = @"D:\temp\001\1.xml"; string DescPath = @"e:\myData\001\1.xml";AutoCreateDirAndCopyFile(SourcePath,DescPath);}private void AutoCreateDirAndCopyFile(string SourcePath,string DescPath){ FileInfo fi = new FileInfo(DescPath); if (!Directory.Exists(fi.DirectoryName)) { Directory.CreateDirectory(fi.DirectoryName); } File.Copy(SourcePath, DescPath);} FileSystemWatcher 类能实现同步复制。 全局模拟按键的问题 C#中datagridview选中行后textbox显示选中的内容 求个正则 CMD命令创建文件夹 请教? C#可以开发出像鱼鱼那样的漂亮的图形桌面软件吗? 次方函数是哪个 用serialPort类串口通讯,需要清理缓冲区吗? 元旦就要到了,祝大家元旦快乐!!! 菜单的起始位置 谁能详细说说它们的区别 aspnet_wp进程占用内存越来越大的问题 请教,VS2003平台,winform下的datagrid加载时,自动展开所有列,即每个列的宽度都足够容纳其内容
string destFileName = @"c:\a\a\a.txt";
string destDir = Path.GetDirectoryName(destFileName);
if (!Directory.Exists(destDir))
{
Directory.CreateDirectory(destDir);
}
File.Copy(sourceFileName, destFileName);
private void CopyFile()
{
string SourcePath = @"D:\temp\001\1.xml";
string DescPath = @"e:\myData\001\1.xml";
AutoCreateDirAndCopyFile(SourcePath,DescPath);
}
private void AutoCreateDirAndCopyFile(string SourcePath,string DescPath)
{
FileInfo fi = new FileInfo(DescPath);
if (!Directory.Exists(fi.DirectoryName))
{
Directory.CreateDirectory(fi.DirectoryName);
}
File.Copy(SourcePath, DescPath);
}