/// <summary> /// Returns IFolder corresponding to path. /// </summary> /// <param name="path">Path to the folder.</param> /// <returns>Folder corresponding to requested path.</returns> public IFolder OpenFolder(Uri path) { var folder = new WebDavFolder(); folder.SetCredentials(Credentials); folder.Open(path); return folder; }
/// <summary> /// Returns IFolder corresponding to path. /// </summary> /// <param name="path">Path to the folder.</param> /// <returns>Folder corresponding to requested path.</returns> public IFolder OpenFolderPaged(string path) { var folder = new WebDavFolder(); folder.SetCredentials(Credentials); folder.OpenPaged(path); return folder; }
/// <summary> /// Creates new folder with specified name as child of this one. /// </summary> /// <param name="name">Name of the new folder.</param> /// <returns>IFolder</returns> public IFolder CreateFolder(string name) { var folder = new WebDavFolder(); try { var credentials = (NetworkCredential)_credentials; var request = (HttpWebRequest)WebRequest.Create(Href.AbsoluteUri + name); request.Method = "MKCOL"; request.Credentials = credentials; string auth = "Basic " + Convert.ToBase64String( Encoding.Default.GetBytes(credentials.UserName + ":" + credentials.Password)); request.Headers.Add("Authorization", auth); using (var response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.NoContent) { folder.SetCredentials(_credentials); folder.Open(Href.AbsoluteUri + name + "/"); } } } catch (Exception e) { } return(folder); }
/// <summary> /// Returns IFolder corresponding to path. /// </summary> /// <param name="path">Path to the folder.</param> /// <returns>Folder corresponding to requested path.</returns> public IFolder OpenFolder(Uri path) { WebDavFolder folder = new WebDavFolder(); folder.SetCredentials(this.Credentials); folder.Open(path); return(folder); }
/// <summary> /// Returns IFolder corresponding to path. /// </summary> /// <param name="path">Path to the folder.</param> /// <returns>Folder corresponding to requested path.</returns> public IFolder OpenFolderPaged(string path) { var folder = new WebDavFolder(); folder.SetCredentials(Credentials); folder.OpenPaged(path); return(folder); }
/// <summary> /// Creates new folder with specified name as child of this one. /// </summary> /// <param name="name">Name of the new folder.</param> /// <returns>IFolder</returns> public IFolder CreateFolder(string name) { var folder = new WebDavFolder(); try { var credentials = (NetworkCredential) _credentials; var request = (HttpWebRequest) WebRequest.Create(Href.AbsoluteUri + name); request.Method = "MKCOL"; request.Credentials = credentials; string auth = "Basic " + Convert.ToBase64String( Encoding.Default.GetBytes(credentials.UserName + ":" + credentials.Password)); request.Headers.Add("Authorization", auth); using (var response = (HttpWebResponse) request.GetResponse()) { if (response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.NoContent) { folder.SetCredentials(_credentials); folder.Open(Href.AbsoluteUri + name + "/"); } } } catch (Exception e) { } return folder; }
/// <summary> /// Creates new folder with specified name as child of this one. /// </summary> /// <param name="name">Name of the new folder.</param> /// <returns>IFolder</returns> public IFolder CreateFolder(string name) { WebDavFolder folder = new WebDavFolder(); try { NetworkCredential credentials = (NetworkCredential)this._credentials; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(this.Href.AbsoluteUri + name); request.Method = "MKCOL"; request.Credentials = credentials; string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(credentials.UserName + ":" + credentials.Password)); request.Headers.Add("Authorization", auth); Console.WriteLine("Create WebDav Folder: " + this.Href.AbsoluteUri + name); using(HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Console.WriteLine("Response..."); if (response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.NoContent) { folder.SetCredentials(this._credentials); folder.Open(this.Href.AbsoluteUri + name + "/"); } } } catch(Exception e) { Console.WriteLine(e.Message); } return folder; }
/// <summary> /// Returns IFolder corresponding to path. /// </summary> /// <param name="path">Path to the folder.</param> /// <returns>Folder corresponding to requested path.</returns> public IFolder OpenFolder (string path) { WebDavFolder folder = new WebDavFolder(); folder.SetCredentials(this.Credentials); folder.Open(path); return folder; }