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

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

c#復制文件

2019-11-14 09:12:36
字體:
來源:轉載
供稿:網友
        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不包含文件名稱
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙江县| 湄潭县| 吉水县| 镇原县| 临夏县| 醴陵市| 临沭县| 本溪| 常宁市| 满洲里市| 天镇县| 广德县| 英吉沙县| 集安市| 阳高县| 旬邑县| 民县| 大同市| 鄂州市| 改则县| 若尔盖县| 嘉义县| 全州县| 绍兴县| 会泽县| 姜堰市| 英德市| 林周县| 延长县| 万山特区| 固阳县| 河曲县| 长治县| 综艺| 个旧市| 蓬莱市| 佛教| 德惠市| 扶沟县| 达孜县| 怀集县|