コード例 #1
0
ファイル: CloudDebug_Form.cs プロジェクト: DrTexx/RTCV
        public static string CloudSave(string filepath)
        {
            WebRequest.DefaultWebProxy = null;

            string remoteUri = CorruptCloudServer + "/post.php?submit=true&action=upload";

            byte[] responseBinary;
            try
            {
                WebClientTimeout client = new WebClientTimeout();
                responseBinary = client.UploadFile(remoteUri, "POST", filepath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong with the upload. Try again. \n\n\n" + ex.ToString());
                return("");
            }

            string response = Encoding.UTF8.GetString(responseBinary);

            if (response == "ERROR")
            {
                return("");
            }
            else
            {
                return(response);
            }
        }
コード例 #2
0
ファイル: CloudDebug_Form.cs プロジェクト: DrTexx/RTCV
        public static string CloudLoad(string filename, string password)
        {
            string remoteUri = CorruptCloudServer + "/FILES/";

            WebClientTimeout myWebClient = new WebClientTimeout();

            string downloadfilepath;

            SaveFileDialog saveFileDialog1 = new SaveFileDialog
            {
                DefaultExt       = "7z",
                Title            = "Browse path for 7z File",
                Filter           = "7z files|*.7z",
                RestoreDirectory = true
            };

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                downloadfilepath = saveFileDialog1.FileName;
            }
            else
            {
                return(null);
            }

            if (File.Exists(downloadfilepath))
            {
                File.Delete(downloadfilepath);
            }

            try
            {
                myWebClient.DownloadFile(remoteUri + filename, downloadfilepath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Couldn't download requested Debug file\n\n\n" + ex.ToString());
                return(null);
            }

            return(downloadfilepath);
        }