示例#1
0
        public static void Copy(string src, string dst)
        {
            bool isFile = File.Exists(src);
            bool isDir  = Directory.Exists(src);

            if (!isFile && !isDir)
            {
                throw new ArgumentException("[" + src + "] doesn't exist");
            }
            try
            {
                if (isFile)
                {
                    if (Directory.Exists(dst))
                    {
                        string filename = Path.GetFileName(src);
                        dst = Path.Combine(dst, filename);
                    }

                    File.Copy(src, dst, true);
                }
                else
                {
                    Utils.DirectoryCopy(src, dst);
                }
            }
            catch (Exception exc)
            {
                throw new ArgumentException("Couldn't copy to [" + dst + "]: " + exc.Message);
            }
        }