1.使用DirectoryInfo.MoveTo时,将目标文件夹一定要是不存在,不然报错。
代码如下:
1 string path = @"c:\wtqCreate";
2 string pathTxt = path + @"\my.txt";
3 string wtqPath = @"c:\wtq";
4 string wttqq = @"c:\wttq11";
5 DirectoryInfo di = new DirectoryInfo(path);
6 di.MoveTo(wttqq);
2 string pathTxt = path + @"\my.txt";
3 string wtqPath = @"c:\wtq";
4 string wttqq = @"c:\wttq11";
5 DirectoryInfo di = new DirectoryInfo(path);
6 di.MoveTo(wttqq);