百度网盘下载和上传工具。BaiduPCS 项目的 .net 4.0 封装。 图形界面,多线程上传和下载,断点续传,上传和下载目录。
public frmMain()
{
InitializeComponent();
lvFileList.DoubleClick = lvFileList_DoubleClick;
lvFileList.KeyDown = lvFileList_KeyDown;
lvFileList.ColumnClick = LvFileList_ColumnClick;
txSearchKeyword.GotFocus = txSearchKeyword_GotFocus;
txSearchKeyword.LostFocus = txSearchKeyword_LostFocus;
txSearchKeyword.KeyPress = txSearchKeyword_KeyPress;
cmbLocation.KeyPress = cmbLocation_KeyPress;
history = new Stack<string>();
next = new Stack<string>();
sources = new List<PcsFileInfo>();
worker = new DUWorker();
worker.workfolder = GetWorkFolder();
worker.OnCompleted = worker_OnCompleted;
ReadAppSettings();
tempFileName = System.IO.Path.GetTempFileName();
}
private void Form1_Load(object sender, EventArgs e)
{
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (pcs == null)
{
bool succ = true;
ExecTask("Login", "Logging in ...",
new ThreadStart(delegate()
{
try
{
if (!createBaiduPCS())
{
succ = false;
this.Invoke(new AnonymousFunction(delegate()
{
Close();
//MessageBox.Show("Can't create BaiduPCS");
Application.Exit();
}));
return;
}
}
catch(Exception ex)
{
succ = false;
this.Invoke(new AnonymousFunction(delegate()
{
MessageBox.Show("Can't create BaiduPCS: " ex.Message);
Close();
Application.Exit();
}));
return;
}
}),
new ThreadStart(delegate()
{
if (!succ)
return;
this.Invoke(new AnonymousFunction(delegate()
{
Go("/");
worker.pcs = pcs;
worker.Start();
if (AppSettings.ResumeDownloadAndUploadOnStartup)
worker.Resume();
}));
}));
}
}
protected override void OnClosing(CancelEventArgs e)
{
if (frmHistory != null)
frmHistory.Close();
worker.Stop();
if (File.Exists(tempFileName))
{
try { File.Delete(tempFileName); }
catch { }
}
base.OnClosing(e);
}
评论