国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

c#復制文件

2019-11-14 09:51:46
字體:
來源:轉載
供稿:網友
        PRivate bool CopyFolder(string from, string to)        {            try            {                if (!Directory.Exists(to))                    Directory.CreateDirectory(to);                if (File.Exists(from))                {                    FileInfo f = new FileInfo(from);                    f.CopyTo(to + "//" + f.Name, true);                    // 是文件                }                else if (Directory.Exists(from))                {                    // 子文件夾                    foreach (string sub in Directory.GetDirectories(from))                        CopyFolder(sub + "//", to + "//" + Path.GetFileName(sub) + "//");                    // 文件                    foreach (string file in Directory.GetFiles(from))                    {                        if (Path.GetFileName(file).IndexOf("log") < 0 && Path.GetFileName(file).IndexOf("deploy") < 0)                            //File.Copy(file, to + "//" + Path.GetFileName(file), true);//可以覆蓋                        File.Copy(file, Path.Combine(to ,Path.GetFileName(file)), true);//可以覆蓋                                            }                    // 是文件夾                }                else                {                    // MessageBox.Show(from + "不是有效文件或路徑!");                    return false;                }            }            catch (Exception ex)            {                MessageBox.Show(ex.ToString());                return false;            }            return true;        }File.Copy(path1, Path.Combine(path2, Path.GetFileName(path1), true)//,這就可以覆蓋掉同名文件了File.Copy(file, Path.Combine(to ,Path.GetFileName(file)), true);//這個成功,但是to不包含文件名稱
上一篇:【模板】二維樹狀數組

下一篇:麥森數

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 康乐县| 阿瓦提县| 历史| 疏勒县| 华安县| 石柱| 永丰县| 临澧县| 文成县| 东光县| 蚌埠市| 清流县| 嘉兴市| 五台县| 池州市| 青浦区| 岢岚县| 台湾省| 贡觉县| 威海市| 巨野县| 马鞍山市| 潞城市| 潼南县| 峨山| 濮阳县| 平遥县| 张家港市| 徐州市| 孟津县| 神农架林区| 满城县| 临夏市| 禄丰县| 永平县| 嫩江县| 拉萨市| 高阳县| 微山县| 盈江县| 盈江县|