Exemplo n.º 1
0
/// <summary>
/// Copy file including SharePoint support
/// </summary>
/// <param name="?"></param>

        public static void CopyFile(
            string sourceFileName,
            string destFileName)
        {
            if (!SharePointUtil.IsSharePointName(sourceFileName) &&
                !SharePointUtil.IsSharePointName(destFileName))
            {             // both regular files
                File.Copy(sourceFileName, destFileName, true);
            }

            else if (SharePointUtil.IsSharePointName(sourceFileName) &&
                     SharePointUtil.IsSharePointName(destFileName))
            {             // both SharePoint
                string tempFile = TempFile.GetTempFileName();
                SharePointUtil.CopyFromSharePoint(sourceFileName, tempFile);
                SharePointUtil.CopyToSharePoint(tempFile, destFileName);
                File.Delete(tempFile);
            }

            else if (SharePointUtil.IsSharePointName(sourceFileName))             // source only is SharePoint
            {
                SharePointUtil.CopyFromSharePoint(sourceFileName, destFileName);
            }

            else             // dest only is SharePoint
            {
                SharePointUtil.CopyToSharePoint(sourceFileName, destFileName);
            }

            return;
        }
Exemplo n.º 2
0
        /// <summary>
        /// If SharePoint file create a local cached copy of the file that can be read directly
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>

        public static string CacheLocalCopyIfSharePointFile(string path)
        {
            if (!IsSharePointName(path))
            {
                return(path);
            }

            string ext      = IO.Path.GetExtension(path);        // use same extension
            string tempFile = TempFile.GetTempFileName(ext);

            SharePointUtil.CopyFromSharePoint(path, tempFile);
            return(tempFile);
        }