Exemplo n.º 1
0
        /// <summary>
        /// See if file can be opened for reading, return error message if not
        /// </summary>
        /// <param name="path"></param>

        public static string CanReadFile(
            string path)
        {
            try
            {
                bool isNormalFilePath = (!SharePointUtil.IsSharePointName(path));

                if (isNormalFilePath)
                {
                    FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
                    fs.Close();
                }

                else
                {
                    return(SharePointUtil.CanReadFile(path));
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return("");
        }
Exemplo n.º 2
0
/// <summary>
/// Return true if file exists
/// </summary>
/// <param name="path"></param>
/// <returns></returns>

        public static bool Exists(
            string path)
        {
            if (!SharePointUtil.IsSharePointName(path))
            {
                if (File.Exists(path))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            else
            {
                if (Lex.IsNullOrEmpty(SharePointUtil.CanReadFile(path)))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }