Exemplo n.º 1
0
        public void MakeDirectory(ref Content Files, ref DataUser User, ListView ListFiles, TextBox NewFolder, string Folder)
        {
            Rename Active = new Rename();

            if (Active.CheckName(Folder, Files))
            {
                if (User.CheckIntConnect())
                {
                    ReqRes Act = new ReqRes();
                    try
                    {
                        HttpWebRequest Request = Act.MakeRequest(User.Data.UrlServer, User.Data.Hrefs.Last() + Folder, User.Data.Name, User.Data.Password);
                        if (Request != null)
                        {
                            Request.Method = WebRequestMethods.Http.MkCol;
                            Act.GetResponse(Request);
                            User.InfoFiles(ref Files, ref User, ref ListFiles, User.Data.Hrefs.Last(), true);
                            NewFolder.Text = "";
                        }
                    }
                    catch (WebException ex)
                    {
                        if (GotMessage != null)
                        {
                            GotMessage(ex.Message);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void Delete(object it)
 {
     if (InterUser.CheckIntConnect())
     {
         int index = (int)it;
         if (InterFiles.All[index].Href != InterUser.Data.Hrefs.Last())
         {
             ReqRes Act = new ReqRes();
             try
             {
                 HttpWebRequest Request = Act.MakeRequest(InterUser.Data.UrlServer, InterFiles.All[index].Href, InterUser.Data.Name, InterUser.Data.Password);
                 Request.Method = "DELETE";
                 Act.GetResponse(Request);
             }
             catch (WebException ex)
             {
                 if (GotMessage != null)
                 {
                     GotMessage(ex.Message);
                 }
             }
         }
     }
     handle.Set();
 }
Exemplo n.º 3
0
 public bool MakeNewName(DataUser User, int Item, string Name, Content Files)
 {
     if (User.CheckIntConnect())
     {
         ReqRes Act = new ReqRes();
         try
         {
             HttpWebRequest Request = Act.MakeRequest(User.Data.UrlServer, Files.All[Item].Href, User.Data.Name, User.Data.Password);
             Request.Method = "MOVE";
             Request.Accept = "*/*";
             string NewName = User.Data.Hrefs.Last() + Name;
             if (Files.All[Item].ContentType == "d:collection")
             {
                 NewName += "/";
             }
             Request.Headers.Add("Destination: " + HttpUtility.UrlPathEncode(NewName));
             Act.GetResponse(Request);
             return(true);
         }
         catch (WebException ex)
         {
             if (GotMessage != null)
             {
                 GotMessage(ex.Message);
             }
             return(false);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
 private void Upload(object it)
 {
     if (InterUser.CheckIntConnect())
     {
         int    index = (int)it;
         ReqRes Act   = new ReqRes();
         try
         {
             HttpWebRequest Request    = Act.MakeRequest(InterUser.Data.UrlServer, InterUser.Data.Hrefs.Last() + SafeNames[index], InterUser.Data.Name, InterUser.Data.Password);
             FileStream     ReadStream = new FileStream(Names[index], FileMode.Open, FileAccess.Read);
             Request.Method                         = WebRequestMethods.Http.Put;
             Request.ContentLength                  = ReadStream.Length;
             Request.KeepAlive                      = false;
             Request.ReadWriteTimeout               = -1;
             Request.Timeout                        = -1;
             Request.AllowWriteStreamBuffering      = true;
             Request.PreAuthenticate                = false;
             Request.SendChunked                    = false;
             Request.ContentType                    = "application/binary";
             Request.ProtocolVersion                = HttpVersion.Version11;
             Request.ServicePoint.ConnectionLimit   = 1;
             Request.AllowAutoRedirect              = false;
             Request.ServicePoint.Expect100Continue = true;
             Request.Accept                         = "*/*";
             Stream reqStream = Request.GetRequestStream();
             if (reqStream != null)
             {
                 byte[] inData    = new byte[8192];
                 int    bytesRead = ReadStream.Read(inData, 0, inData.Length);
                 while (bytesRead > 0)
                 {
                     reqStream.Write(inData, 0, bytesRead);
                     bytesRead = ReadStream.Read(inData, 0, inData.Length);
                 }
                 ReadStream.Close();
                 reqStream.Close();
                 Act.GetResponse(Request);
             }
         }
         catch (WebException ex)
         {
             if (GotMessage != null)
             {
                 GotMessage(ex.Message);
             }
         }
     }
     handle.Set();
 }
Exemplo n.º 5
0
        private void Connection(string UserName, string Password)
        {
            DataUser User = new DataUser();

            if (User.CheckIntConnect())
            {
                ReqRes         Act       = new ReqRes();
                string         UrlServer = "https://webdav.yandex.ru";
                HttpWebRequest Request   = Act.MakeRequest(UrlServer, "", UserName, Password);
                if (Request != null)
                {
                    Request.Accept = "*/*";
                    Request.Headers.Add("Depth: 1");
                    Request.Method = "PROPFIND";
                    Act.GetResponse(Request);
                    {
                        MainForm Main = new MainForm(UrlServer, UserName, Password, this);
                        Main.Show();
                        this.Hide();
                    }
                }
            }
        }
Exemplo n.º 6
0
 private void Paste(object it)
 {
     if (InterUser.CheckIntConnect())
     {
         int    index = (int)it;
         ReqRes Act   = new ReqRes();
         try
         {
             HttpWebRequest Request = Act.MakeRequest(InterUser.Data.UrlServer, InterFiles.CopyHref[index], InterUser.Data.Name, InterUser.Data.Password);
             Request.Method = "COPY";
             Request.Accept = "*/*";
             Request.Headers.Add("Destination: " + HttpUtility.UrlPathEncode(InterUser.Data.Hrefs.Last() + InterFiles.CopyName[index]));
             Act.GetResponse(Request);
         }
         catch (WebException ex)
         {
             if (GotMessage != null)
             {
                 GotMessage(ex.Message);
             }
         }
     }
     handle.Set();
 }