我想在我的上传过程中显示上传过程的进度ProgressBar,这是我的按钮"上传"的代码:
private void button2_Click(object sender, EventArgs e)
{
int Port = int.Parse(textBox2.Text);
string Host = textBox1.Text;
string Username = textBox3.Text;
string Password = textBox4.Text;
string WorkingDirectory = textBox6.Text;
string UploadDirectory = textBox5.Text;
FileInfo FI = new FileInfo(UploadDirectory);
string UploadFile = FI.FullName;
Console.WriteLine(FI.Name);
Console.WriteLine("UploadFile" + UploadFile);
var Client = new SftpClient(Host, Port, Username, Password);
Client.Connect();
if (Client.IsConnected)
{
var FS = new FileStream(UploadFile, FileMode.Open);
if (FS != null)
{
Client.UploadFile(FS, WorkingDirectory + FI.Name, null);
Client.Disconnect();
Client.Dispose();
MessageBox.Show(
"Upload complete", …Run Code Online (Sandbox Code Playgroud) 我想在 UWP 应用程序的标题栏中添加一个新按钮,如下所示:

我已经看到了一些“类似”的帖子,但答案并不明确,而且缺乏细节,我很难理解他们做了什么。
我想在我的网站上显示下载过程的进度ProgressBar.我尝试过这样的代码来上传,但我失败了.这是我尝试失败的一个例子
private void button5_Click(object sender, EventArgs e)
{
Task.Run(() => Download());
}
private void Download()
{
try
{
int Port = (int)numericUpDown1.Value;
string Host = comboBox1.Text;
string Username = textBox3.Text;
string Password = textBox4.Text;
string SourcePath = textBox5.Text;
string RemotePath = textBox6.Text;
string FileName = textBox7.Text;
using (var file = File.OpenWrite(SourcePath + FileName))
using (var Stream = new FileStream(SourcePath + FileName, FileMode.Open))
using (var Client = new SftpClient(Host, Port, Username, Password))
{
Client.Connect();
progressBar1.Invoke((MethodInvoker)
delegate
{ …Run Code Online (Sandbox Code Playgroud)