当前位置: 代码迷 >> C# >> C#步骤中没有采用“0”个参数重载
  详细解决方案

C#步骤中没有采用“0”个参数重载

热度:233   发布时间:2016-05-05 05:08:49.0
C#方法中没有采用“0”个参数重载
小弟在网上找了个将一个文件夹下的东西复制到另一个文件夹下,自己谢了下,出现错误:C#方法中没有采用“0”个参数重载
代码如下,请大神们指出,说的清楚些,小弟谢谢啦!
private bool CopyFloderContents(string OldPath, string NewPath)
        {
            OldPath = OldPath.EndsWith(@"D:\123") ? OldPath : OldPath + @"D:\123";
            NewPath = NewPath.EndsWith(@"D:\aaa") ? NewPath : NewPath + @"D:\aaa";
            try
            {
                if (Directory.Exists(OldPath))
                {
                    if (Directory.Exists(NewPath) == false)
                    {
                        Directory.CreateDirectory(NewPath);
                    }
                    foreach (string files in Directory.GetFiles(OldPath))
                    {
                        FileInfo fileinfo = new FileInfo(files);
                        fileinfo.CopyTo(string.Format(@"{0}\{1}", NewPath, fileinfo.Name), true);
                    }
                    foreach (string drs in Directory.GetDirectories(OldPath))
                    {
                        DirectoryInfo directoryInfo = new DirectoryInfo(drs);
                        if (CopyFloderContents(drs, NewPath + directoryInfo.Name) == false)
                        {
                            return false;
                        }
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CopyFloderContents();//CopyFloderContents方法中没有采用“0”个参数重载
        }
    }
------解决思路----------------------
CopyFloderContents需要两个参数,你不给传参数哪行
CopyFloderContents("a","b")
------解决思路----------------------
引用:
...谢谢各位,是不是这样写就可以了
CopyFloderContents("OldPath", "NewPath");

这里面要填写路径啊,你填写的这两个字符串也不是路径啊
  相关解决方案