//附件下载事件
private void btnDownLoad_Click(object sender, EventArgs e)
{
if (lstFTP.SelectedItem != null)
{
string tFileName = lstFTP.SelectedItem.ToString();
int tIndex = tFileName.IndexOf(' ');
if (tIndex >= 0 && tFileName.Length > tFileName.Length - tIndex)
tFileName = tFileName.Substring(tIndex + 1, tFileName.Length - tIndex - 1);
tFileName = tFileName.Trim();
//string nUri = txtFtpUri.Text + "/" + tFileName;
string nUri = nUridz + tFileName;
DownloadProgressChangedEventHandler nProgressDlg = new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
AsyncCompletedEventHandler nCompletedDlg = new AsyncCompletedEventHandler(client_DownloadFileCompleted);
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = tFileName;
sfd.Filter = "所有文件(*.*)|*.*";
sfd.ShowDialog();
if (!sfd.FileName.Equals(string.Empty))
{
//gFtp.DownloadFileAsync(nUri, Path.Combine(_saveDir, tFileName), nProgressDlg, nCompletedDlg);
gFtp.DownloadFileAsync(nUri, sfd.FileName, nProgressDlg, nCompletedDlg);
}
}
}
//下载完成
public void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Error == null)
{
lblMessage.Text = "下载完成";
}
}
//附件下载动画
public void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
this.proBarDownLoad.Minimum = 0;
this.proBarDownLoad.Maximum = (int)gFtp.UriFileTotleSize;
this.proBarDownLoad.Value = (int)e.BytesReceived;
float f_total = gFtp.UriFileTotleSize;
float f_value = e.BytesReceived;
if (f_total <= 0)
return;
float tPercent = f_value / f_total * 100;
this.lblercent_Down.Text = (int)tPercent + "%";
} //附件下载事件
private void btnDownLoad_Click(object sender, EventArgs e)
{
if (lstFTP.SelectedItem != null)
{
string tFileName = lstFTP.SelectedItem.ToString();
int tIndex = tFileName.IndexOf(' ');
if (tIndex >= 0 && tFileName.Length > tFileName.Length - tIndex)
tFileName = tFileName.Substring(tIndex + 1, tFileName.Length - tIndex - 1);
tFileName = tFileName.Trim();
//string nUri = txtFtpUri.Text + "/" + tFileName;
string nUri = nUridz + tFileName;
DownloadProgressChangedEventHandler nProgressDlg = new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
AsyncCompletedEventHandler nCompletedDlg = new AsyncCompletedEventHandler(client_DownloadFileCompleted);
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = tFileName;
sfd.Filter = "所有文件(*.*)|*.*";
sfd.ShowDialog();
if (!sfd.FileName.Equals(string.Empty))
{
//gFtp.DownloadFileAsync(nUri, Path.Combine(_saveDir, tFileName), nProgressDlg, nCompletedDlg);
gFtp.DownloadFileAsync(nUri, sfd.FileName, nProgressDlg, nCompletedDlg);
}
}
}
//下载完成
public void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
if (e.Error == null)
{
lblMessage.Text = "下载完成";
}
}
//附件下载动画
public void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
this.proBarDownLoad.Minimum = 0;
this.proBarDownLoad.Maximum = (int)gFtp.UriFileTotleSize;
this.proBarDownLoad.Value = (int)e.BytesReceived;
float f_total = gFtp.UriFileTotleSize;
float f_value = e.BytesReceived;
if (f_total <= 0)
return;
float tPercent = f_value / f_total * 100;
this.lblercent_Down.Text = (int)tPercent + "%";
}
gFtp是什么类?自己写的还是使用第三方的库?