private void AddFileToListBox(MyFileInfo fi) { //lst.Items.Add(CreateSP(fi)); fi.Progress = "Vald"; fi.ProgressValue = 0; fi.Uploaded = false; fl.myFileList.Add(fi); //lst.Items.Add(fi); }
private void PushData(System.IO.FileStream input, System.IO.Stream output, MyFileInfo mfi) { byte[] buffer = new byte[4096]; int bytesRead; int iRead = 0; while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0) { iRead = iRead + buffer.Length; mfi.Progress = Math.Round((double.Parse(input.Length.ToString()) / double.Parse(iRead.ToString())) * 100, 0).ToString() + " %"; mfi.ProgressValue = Math.Round((double.Parse(input.Length.ToString()) / double.Parse(iRead.ToString())) * 100, 0); output.Write(buffer, 0, bytesRead); } mfi.Uploaded = true; }
private void UploadFiles(MyFileInfo mfi, System.IO.FileStream data) { UriBuilder ub = new UriBuilder("http://localhost:3793/receiver.ashx"); ub.Query = string.Format("filename={0}&name={1}&address={2}&email={3}&golfid={4}", mfi.Name, fixText(txtName.Text), fixText(txtAdress.Text), fixText(txtEmail.Text), fixText(txtGolfID.Text)); //ub.Query = string.Format("filename={0}", mfi.Name); WebClient wc = new WebClient(); wc.OpenWriteCompleted += (sender, e) => { PushData(data, e.Result, mfi); e.Result.Close(); data.Close(); lbl.Text = "Fil(er) uppladdade!"; }; wc.OpenWriteAsync(ub.Uri); }
private void PushData(System.IO.FileStream input, System.IO.Stream output, MyFileInfo mfi) { byte[] buffer = new byte[4096]; int bytesRead; int iRead = 0; while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0) { iRead = iRead + buffer.Length; mfi.Progress = Math.Round((double.Parse(input.Length.ToString()) / double.Parse(iRead.ToString()))*100, 0).ToString() + " %"; mfi.ProgressValue = Math.Round((double.Parse(input.Length.ToString()) / double.Parse(iRead.ToString())) * 100, 0); output.Write(buffer, 0, bytesRead); } mfi.Uploaded = true; }