国产探花免费观看_亚洲丰满少妇自慰呻吟_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不包含文件名稱
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大方县| 彭州市| 阳东县| 抚远县| 兰溪市| 黄冈市| 民县| 襄汾县| 邓州市| 宣威市| 湘潭县| 定南县| 高安市| 静乐县| 临湘市| 喀喇| 西峡县| 广西| 通河县| 蕲春县| 和平区| 广宁县| 达尔| 体育| 临漳县| 辽阳县| 泽普县| 安吉县| 庆安县| 白山市| 五台县| 龙南县| 古浪县| 德格县| 金阳县| 陆良县| 安陆市| 巴楚县| 宽甸| 达州市| 苍溪县|