Ejemplo n.º 1
0
        public static void CopyFileTo(this IVirtualFile srcfile, IVirtualFile dstfile, CopyFileMode mode)
        {
            if (srcfile.DiskPath != null && dstfile.DiskPath != null && IOTool.FileIsLink(srcfile.DiskPath))
            {
                IOTool.CopyFile(srcfile.DiskPath, dstfile.DiskPath, mode);
                return;
            }
            if (srcfile.DataDiskPath != null && dstfile.DataDiskPath != null)
            {
                IOTool.CopyFile(srcfile.DataDiskPath, dstfile.DataDiskPath, mode);
                return;
            }

            string text = null;

            byte[] data = null;
            try
            {
                text = srcfile.GetText();
            }
            catch (Exception)
            {
                data = srcfile.GetBinary();
            }
            if (text != null)
            {
                dstfile.SaveText(text);
            }
            else
            {
                dstfile.SaveBinary(data);
            }
            if (mode == CopyFileMode.Move)
            {
                srcfile.Remove();
            }
        }