91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 40KB
    文件類型: .rar
    金幣: 2
    下載: 1 次
    發布日期: 2021-06-12
  • 語言: C#
  • 標簽: 異步??

資源簡介

C#實現異步拷貝多個文件到指定的目錄,以及數據線程訪問ui線程控件的方法。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;
using?System.Threading;

namespace?DelegateTest
{
????public?partial?class?Form1?:?Form
????{
????????FileStream?fs?=?null;
????????
????????public?Form1()
????????{
????????????InitializeComponent();
???
????????}

????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????OpenFileDialog?dialog?=?new?OpenFileDialog();
????????????dialog.title?=?“選定文件“;
????????????dialog.Multiselect?=?true;
????????????if?(dialog.ShowDialog()?==?DialogResult.OK)
????????????{
????????????????string[]?filenames?=?dialog.FileNames;
????????????????foreach(string?str?in?filenames)
????????????????{
????????????????????string?realname?=str.Substring(?str.LastIndexOf(‘\\‘)+1);
????????????????????this.comboBox1.Items.Add(new?ComboboxItem(realnamestr));

????????????????}
????????????????this.comboBox1.SelectedIndex?=?0;
????????????}
????????}

????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????FolderBrowserDialog?dialog?=?new?FolderBrowserDialog();
????????????dialog.ShowNewFolderButton?=?true;
????????????
????????????if?(dialog.ShowDialog()?==?DialogResult.OK)
????????????{
????????????????this.textBox1.Text?=?dialog.SelectedPath;
????????????}
????????}

????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????Rectangle?rect?=?System.Windows.Forms.SystemInformation.WorkingArea;
????????????this.Left?=?(rect.Width?-?this.Width)?/?2;
????????????this.Top?=?(rect.Height?-?this.Height)?/?2;
????????}

????????public?delegate?bool?CopyFileToDesPathEventHadler(string[]?filenamestring?path);
????????private?bool?CopyFileToDesPath(string[]?filenamestring?path)?
????????{
????????????foreach(string?str?in?filename)
????????????{
????????????????try
????????????????{
????????????????????FileStream?fr?=?new?FileStream(strFileMode.OpenFileAccess.Read);
????????????????????string?realname=str.Substring(?str.LastIndexOf(‘\\‘)+1);
????????????????????FileStream?fw?=?new?FileStream(path+“\\“+realnameFileMode.CreateFileAccess.Write);
????????????????????byte[]?buffer?=?new?byte[1024];
????????????????????int?length?=?fr.Read(buffer0buffer.Length);
????????????????????while(length!=0)
????????????????????{
????????????????????????fw.Write(buffer0length);
????????????????????????fw.Flush();
????????????????????????length?=?fr.Read(buffer0buffer.Length);
????????????????????}
????????????????????fr.Close();
????????????????????fw.Close();
????????????????????this.SetListBox(str);
????????????????????Thread.Sleep(2000);
????????????????}
????????????????catch?(Exception?e)?{
????????????????????MessageBox.Show(e.ToString());
????????????????}
????????????}
????????????return?false;
????????}
????????publ

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????12288??2012-08-02?14:44??DelegateTest\bin\Debug\DelegateTest.exe

?????文件??????28160??2012-08-02?14:44??DelegateTest\bin\Debug\DelegateTest.pdb

?????文件??????14328??2012-08-06?17:45??DelegateTest\bin\Debug\DelegateTest.vshost.exe

?????文件????????490??2009-06-11?05:14??DelegateTest\bin\Debug\DelegateTest.vshost.exe.manifest

?????文件???????3770??2012-08-01?17:50??DelegateTest\DelegateTest.csproj

?????文件???????4586??2012-08-02?14:44??DelegateTest\Form1.cs

?????文件???????6509??2012-08-02?14:33??DelegateTest\Form1.Designer.cs

?????文件???????5814??2012-08-02?14:33??DelegateTest\Form1.resx

?????文件????????607??2012-08-06?17:45??DelegateTest\obj\Debug\DelegateTest.csproj.FileListAbsolute.txt

?????文件????????847??2012-08-02?14:33??DelegateTest\obj\Debug\DelegateTest.csproj.GenerateResource.Cache

?????文件??????12288??2012-08-02?14:44??DelegateTest\obj\Debug\DelegateTest.exe

?????文件????????180??2012-08-02?14:33??DelegateTest\obj\Debug\DelegateTest.Form1.resources

?????文件??????28160??2012-08-02?14:44??DelegateTest\obj\Debug\DelegateTest.pdb

?????文件????????180??2012-08-01?17:50??DelegateTest\obj\Debug\DelegateTest.Properties.Resources.resources

?????文件????????493??2012-08-01?17:46??DelegateTest\Program.cs

?????文件???????1356??2012-08-01?17:46??DelegateTest\Properties\AssemblyInfo.cs

?????文件???????2874??2012-08-01?17:46??DelegateTest\Properties\Resources.Designer.cs

?????文件???????5612??2012-08-01?17:46??DelegateTest\Properties\Resources.resx

?????文件???????1097??2012-08-01?17:46??DelegateTest\Properties\Settings.Designer.cs

?????文件????????249??2012-08-01?17:46??DelegateTest\Properties\Settings.settings

?????目錄??????????0??2012-08-02?15:57??DelegateTest\obj\Debug\Refactor

?????目錄??????????0??2012-08-01?17:46??DelegateTest\obj\Debug\TempPE

?????目錄??????????0??2012-08-01?17:50??DelegateTest\bin\Debug

?????目錄??????????0??2012-08-02?15:57??DelegateTest\obj\Debug

?????目錄??????????0??2012-08-01?17:46??DelegateTest\bin

?????目錄??????????0??2012-08-01?17:46??DelegateTest\obj

?????目錄??????????0??2012-08-01?17:46??DelegateTest\Properties

?????目錄??????????0??2012-08-02?14:44??DelegateTest

-----------?---------??----------?-----??----

???????????????129888????????????????????28

............此處省略1個文件信息

評論

共有 條評論