Exemplo n.º 1
0
        /// <summary>
        /// 复制文件夹到指定路径
        /// </summary>
        /// <param name="sourcePath">要复制的文件夹所在路径(如: "H:\\图片")</param>
        /// <param name="targetPath">目的路径(如: "D:\\新建文件夹")</param>
        /// <returns></returns>
        public static ReturnMessageFormat CopyFolder(string sourcePath, string targetPath)
        {
            ReturnMessageFormat message = new ReturnMessageFormat();
            List <string>       error   = new List <string>();

            informationFormat.fileManagerFormat.TreeNode tree = new informationFormat.fileManagerFormat.TreeNode();
            tree.setFullName(sourcePath);
            tree.copyTo(targetPath, ref error);

            if (error.Count == 0)
            {
                message.status  = Order.success;
                message.message = "";
                message.data    = null;
            }
            else
            {
                string temp = string.Empty;
                foreach (string str in error)
                {
                    temp += ("错误信息" + str);
                }
                message.status  = Order.failure;
                message.message = temp.Length > 2000 ? "复制文件夹出错" : temp;
                message.data    = null;
            }
            return(message);
        }