Exemple #1
0
		/// <summary>
		/// List the specified remote path.
		/// </summary>
		/// <param name="path">remote Path.</param>
		/// <returns>List of Resources.</returns>
		public List<ResourceInfo> List(string path) {
			List<ResourceInfo> resources = new List<ResourceInfo> ();
			var result = this.dav.List (GetDavUri(path));

			foreach (var item in result) {
				if (item == result[0]) // Skip the first element, since it is always the root
					continue;
				
				ResourceInfo res = new ResourceInfo ();
				if (item.IsDirectory) // if resource is a directory set special content type
					res.ContentType = "dav/directory";
				else
					res.ContentType = item.ContentType;
				res.Created = item.Created;
				res.ETag = item.Etag;
				res.LastModified = item.Modified;
				res.Name = item.Name;
				res.QuotaAvailable = item.QutoaAvailable;
				res.QuotaUsed = item.QuotaUsed;
				res.Size = item.Size;
				res.Path = item.Uri.AbsolutePath.Replace("/" + davpath, "");
				if (!res.ContentType.Equals ("dav/directory")) // if resource not a directory, remove the file name from remote path.
					res.Path = res.Path.Replace ("/" + res.Name, "");
				resources.Add (res);
			}

			return resources;
		}
Exemple #2
0
		/// <summary>
		/// Gets the resource info for the remote path.
		/// </summary>
		/// <returns>The resource info.</returns>
		/// <param name="path">remote Path.</param>
		public ResourceInfo GetResourceInfo(string path) {
			var result = this.dav.List (GetDavUri(path));

			if (result.Count > 0) {
				var item = result [0];
				ResourceInfo res = new ResourceInfo ();
				if (item.IsDirectory) // if resource is a directory set special content type
					res.ContentType = "dav/directory";
				else
					res.ContentType = item.ContentType;
				res.Created = item.Created;
				res.ETag = item.Etag;
				res.LastModified = item.Modified;
				res.Name = item.Name;
				res.QuotaAvailable = item.QutoaAvailable;
				res.QuotaUsed = item.QuotaUsed;
				res.Size = item.Size;
				res.Path = item.Uri.AbsolutePath.Replace("/" + davpath, "");
				if (!res.ContentType.Equals ("dav/directory")) // if resource not a directory, remove the file name from remote path.
					res.Path = res.Path.Replace ("/" + res.Name, "");
				return res;
			}

			return null;
		}