Esempio n. 1
0
        public void CopyFile(string from, string to)
        {
            from = RebasePath(from);
            to   = RebasePath(to);

            if (!File.Exists(from))
            {
                throw ExceptionsFactory.PathNotExist(from);
            }
            if (File.Exists(to))
            {
                while (true)
                {
                    var response = _messenger.Confirm("Output file already exist, rewrite it? (y,n): ");
                    if (!response)
                    {
                        throw ExceptionsFactory.SamePathAlreadyExist(to, nameof(to));
                    }
                    break;
                }
                File.Copy(from, to, true);
            }

            var copyDirectory = Path.GetDirectoryName(to);

            if (!Directory.Exists(copyDirectory))
            {
                Directory.CreateDirectory(copyDirectory);
            }
            File.Copy(from, to);
        }