问题描述
- c#模拟命令提示板上的copy指令
-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;namespace CmdDemo
{
public class Cmd
{
public static void dir()
{
// var path = System.Windows.Forms.Application.StartupPath;
dir(System.Environment.CurrentDirectory);} public static void dir(string path) { DirectoryInfo di = new DirectoryInfo(path); foreach (var d in di.GetDirectories()) { Console.WriteLine("{0}t<DIF>t{1}",d.CreationTime,d.Name); } foreach (var f in di.GetFiles()) { Console.WriteLine("{0}tt{1}", f.CreationTime, f.Name); } Console.WriteLine("tt{0} 个文件",di.GetFiles().Count()); Console.WriteLine("tt{0} 个目录", di.GetDirectories().Count()); } public static void cd(string path) { System.Environment.CurrentDirectory = path; } public static void del(string filePath) { if (!System.IO.File.Exists(filePath)) { Console.WriteLine("找不到{0}", filePath); Console.WriteLine(); return; } System.IO.File.Delete(filePath); } public static void copy(string sourceFileName,string destFileName) { ????? } }
}
我刚刚学习c#,想模拟copy指令。刚刚学习还有很多不懂,上面是代码,求问号地方的代码,我也百度过,看不懂,求指导,谢谢
时间: 2024-09-12 22:51:52