Example #1
0
        /// <summary>
        /// Checks whether file or folder exists on the Saaspose storage.
        /// </summary>
        /// <param name="strFolderOrFile"></param>
        /// <returns></returns>
        public FileExist FileExist(string strFolderOrFile)
        {
            try
            {
                string       strURIRequest = this.strURIExist + strFolderOrFile;
                string       strURISigned  = Utils.Sign(strURIRequest);
                StreamReader reader        = new StreamReader(Utils.ProcessCommand(strURISigned, "GET"));
                string       strJSON       = reader.ReadToEnd();
                JObject      parsedJSON    = JObject.Parse(strJSON);

                ExistResponse existResponse = JsonConvert.DeserializeObject <ExistResponse>(parsedJSON.ToString());

                return(existResponse.FileExist);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// Checks whether file or folder exists on the Saaspose/3rd party storage.
        /// In case of Amazon S3/Google Cloud storages, the folder's path starts with Amazon S3/Google Cloud Bucket name.
        /// </summary>
        /// <param name="strFolderOrFile">In case of Amazon S3/Google Cloud storages, the folder's path starts with Amazon S3/Google Cloud Bucket name.</param>
        /// /// <param name="storageType"></param>
        /// <param name="storageName">Name of the storage</param>
        /// <returns></returns>
        public FileExist FileExist(string strFolderOrFile, StorageType storageType, string storageName)
        {
            try
            {
                //Build URI to check file
                StringBuilder strURI = new StringBuilder(this.strURIExist + strFolderOrFile);

                strURI.Append("?storage=" + storageName);

                string       strURISigned = Utils.Sign(strURI.ToString());
                StreamReader reader       = new StreamReader(Utils.ProcessCommand(strURISigned, "GET"));
                string       strJSON      = reader.ReadToEnd();
                JObject      parsedJSON   = JObject.Parse(strJSON);

                ExistResponse existResponse = JsonConvert.DeserializeObject <ExistResponse>(parsedJSON.ToString());

                return(existResponse.FileExist);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }