public static OpenRes Open(Uri uri, ConnInfo conn) { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri ?? conn.Url); req.Credentials = conn.Auth; req.UserAgent = "OpenyourWebDAV/" + Application.ProductVersion; req.Method = "PROPFIND"; req.Headers["Depth"] = "1"; req.ContentLength = 0; req.PreAuthenticate = true; OpenRes ret = new OpenRes(); ret.baseUrl = req.RequestUri; try { using (HttpWebResponse res = (HttpWebResponse)req.GetResponse()) { ret.xmlo.Load(res.GetResponseStream()); ret.xmlo.Save(Path.GetTempFileName()); } } catch (WebException err) { ret.err = err; } return(ret); }
void Open(Uri uri) { OpenRes res = DInfo.Open(uri, conn); if (res.err == null) { lvF.Items.Clear(); firstNavi = firstNavi ?? navi; navi = res.baseUrl; tbUrl.Text = navi.ToString(); foreach (Ent ent in res.Ents) { if (ent.IsSelf) { lvF.Tag = ent; continue; } ListViewItem lvi = new ListViewItem(ent.Name); Int64? length = ent.ContentLength; lvi.SubItems.Add(length.HasValue ? length.Value.ToString("#,##0") : ""); lvi.SubItems.Add(ent.IsDir ? "フォルダ" : "ファイル"); DateTime?mt = ent.Mt; lvi.SubItems.Add((mt.HasValue) ? mt.Value.ToString() : ""); lvi.ImageKey = ent.IsDir ? "D" : "F"; lvi.Tag = ent; lvF.Items.Add(lvi); } } else { MessageBox.Show(this, "失敗しました:" + res.err.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); if (tbUrl.Text.Length == 0) { tbUrl.Text = (firstNavi = uri).ToString(); } } }
public static OpenRes Open(Uri uri, ConnInfo conn) { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri ?? conn.Url); req.Credentials = conn.Auth; req.UserAgent = "OpenyourWebDAV/" + Application.ProductVersion; req.Method = "PROPFIND"; req.Headers["Depth"] = "1"; req.ContentLength = 0; req.PreAuthenticate = true; OpenRes ret = new OpenRes(); ret.baseUrl = req.RequestUri; try { using (HttpWebResponse res = (HttpWebResponse)req.GetResponse()) { ret.xmlo.Load(res.GetResponseStream()); ret.xmlo.Save(Path.GetTempFileName()); } } catch (WebException err) { ret.err = err; } return ret; }
public Ent(OpenRes ret, XmlElement elres) { this.ret = ret; this.elres = elres; }