예제 #1
0
파일: VForm.cs 프로젝트: windrobin/kumpro
        public static HeadRes Head(Uri uri, ConnInfo conn)
        {
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);

            req.Credentials     = conn.Auth;
            req.UserAgent       = UA;
            req.Method          = "HEAD";
            req.PreAuthenticate = true;

            HeadRes ret = new HeadRes();

            ret.baseUri = uri;
            try {
                using (ret.res = (HttpWebResponse)req.GetResponse()) {
                }
            }
            catch (WebException err) {
                ret.err = err;
            }
            return(ret);
        }
예제 #2
0
파일: VForm.cs 프로젝트: windrobin/kumpro
        public static HeadRes Head(Uri uri, ConnInfo conn) {
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
            req.Credentials = conn.Auth;
            req.UserAgent = UA;
            req.Method = "HEAD";
            req.PreAuthenticate = true;

            HeadRes ret = new HeadRes();
            ret.baseUri = uri;
            try {
                using (ret.res = (HttpWebResponse)req.GetResponse()) {
                }
            }
            catch (WebException err) {
                ret.err = err;
            }
            return ret;
        }
예제 #3
0
파일: VForm.cs 프로젝트: windrobin/kumpro
            public UTRes UploadThem(String[] alfp, Uri baseUri)
            {
                foreach (String fp in alfp)
                {
                    if (cancel.WaitOne(0, false))
                    {
                        return(UTRes.Cancel);
                    }
                    Uri uriTo = UUt.CombineFile(baseUri, Path.GetFileName(fp));
                    using (HeadRes head = DInfo.Head(uriTo, conn)) {
                        head.Dispose();
                        if (0 == (File.GetAttributes(fp) & FileAttributes.Directory))
                        {
                            if (head.Exists)
                            {
                                switch (QueryOvwr(head.baseUri.ToString()))
                                {
                                case DialogResult.Yes:
                                    break;

                                case DialogResult.No:
                                    continue;

                                case DialogResult.Cancel:
                                    return(UTRes.Cancel);
                                }
                            }
                            head.Dispose();
                            using (GenRes uploaded = DInfo.Upload2(uriTo, fp, conn, nio, cancel)) {
                                if (cancel.WaitOne(0, true))
                                {
                                    using (GenRes rest = DInfo.Delete(uriTo, conn)) {
                                    }
                                }
                            }
                            using (GenRes set = DInfo.SetMt(uriTo, fp, conn)) {
                            }
                        }
                        else
                        {
                            Uri uriDir = UUt.CombineFile(baseUri, Path.GetFileName(fp));

                            if (!head.Exists)
                            {
                                using (GenRes newf = DInfo.NewFolder(uriTo, conn)) {
                                    if (!newf.Success)
                                    {
                                        continue;
                                    }
                                }
                            }

                            switch (UploadThem(Directory.GetFileSystemEntries(fp), uriDir))
                            {
                            case UTRes.Cancel:
                                return(UTRes.Cancel);
                            }
                        }
                    }
                }
                return(UTRes.Ok);
            }