├── .gitignore ├── BaiduPCS_NET.sln ├── BaiduPCS_NET ├── BaiduPCS.cs ├── BaiduPCS_NET.csproj ├── Core │ ├── Delegates.cs │ ├── PcsFileInfo.cs │ ├── PcsOption.cs │ ├── PcsPanApiRes.cs │ ├── PcsPanApiResInfo.cs │ ├── PcsRes.cs │ └── SPair.cs ├── Native │ ├── NativeConst.cs │ ├── NativeDelegates.cs │ ├── NativeMethods.cs │ ├── NativePcsFileInfo.cs │ ├── NativePcsFileInfoList.cs │ ├── NativePcsFileInfoListItem.cs │ ├── NativePcsPanApiRes.cs │ ├── NativePcsPanApiResInfo.cs │ ├── NativePcsPanApiResInfoList.cs │ ├── NativePcsSList.cs │ ├── NativePcsSList2.cs │ └── NativeUtils.cs └── Properties │ └── AssemblyInfo.cs ├── LICENSE ├── README.md └── Sample └── Sample_0_FileExplorer ├── Common ├── AnonymousFunction.cs ├── AppSettings.cs ├── MimeMapping.cs ├── SystemIcon.cs └── Utils.cs ├── DU ├── BigFileHelper.cs ├── Cache.cs ├── CompletedEventArgs.cs ├── Downloader.cs ├── IBigFileHelper.cs ├── ICancellable.cs ├── IProgressable.cs ├── MultiThreadDownloader.cs ├── MultiThreadUploader.cs ├── ProgressEventArgs.cs ├── RapidUploader.cs ├── Slice.cs ├── SliceHelper.cs ├── SliceStatus.cs ├── StateFileNameDecideEventArgs.cs ├── ThreadCountChangedEventArgs.cs └── Uploader.cs ├── Forms ├── ListViewItemComparer.cs ├── ListViewProgress.cs ├── frmCaptcha.cs ├── frmCaptcha.designer.cs ├── frmCaptcha.resx ├── frmFileName.Designer.cs ├── frmFileName.cs ├── frmFileName.resx ├── frmHistory.Designer.cs ├── frmHistory.cs ├── frmHistory.resx ├── frmInput.Designer.cs ├── frmInput.cs ├── frmInput.resx ├── frmLogin.cs ├── frmLogin.designer.cs ├── frmLogin.resx ├── frmMain.Designer.cs ├── frmMain.cs ├── frmMain.resx ├── frmMetaInformation.cs ├── frmMetaInformation.designer.cs ├── frmMetaInformation.resx ├── frmProgress.cs ├── frmProgress.designer.cs ├── frmProgress.resx ├── frmSettings.Designer.cs ├── frmSettings.cs ├── frmSettings.resx ├── frmWaiting.cs ├── frmWaiting.designer.cs └── frmWaiting.resx ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── Sample_0_FileExplorer.csproj ├── Worker ├── DUQueue.cs ├── DUWorker.cs ├── DUWorkerPersister.cs └── Operation.cs ├── app.config ├── history-window.png ├── icons ├── arrow-down-32x32.png ├── arrow-left-32x32.png ├── arrow-right-24x24.png ├── arrow-right-32x32.png ├── arrow-up-32x32.png ├── clean-200x200.png ├── clean-32x32.png ├── cloud-32x32.png ├── download-32x32.png ├── download-lightblue-32x32.png ├── download-lightblue.png ├── folder-32x32.png ├── folder.png ├── gear-32x32.png ├── generic-file.png ├── generic-folder.png ├── github.png ├── graphics-32x32.png ├── loading.gif ├── logout-32x32.png ├── pause-200x200.png ├── pause-32x32.png ├── play-200x200.png ├── play-32x32.png ├── refresh-32x32.png ├── remove-32x32.png ├── search-32x32.png ├── upload-2-32x32.png ├── upload-32x32.png ├── upload-orange-32x32.png ├── upload-orange.png ├── user-32x32.png └── wait_bg.png └── main-window.png /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | #Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | -------------------------------------------------------------------------------- /BaiduPCS_NET.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 14.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaiduPCS_NET", "BaiduPCS_NET\BaiduPCS_NET.csproj", "{605B8AE1-834A-459B-9461-7BA72D0212BA}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample_0_FileExplorer", "Sample\Sample_0_FileExplorer\Sample_0_FileExplorer.csproj", "{EAC9410A-0903-431D-87ED-223BFB8653C4}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x86 = Debug|x86 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {605B8AE1-834A-459B-9461-7BA72D0212BA}.Debug|x86.ActiveCfg = Debug|x86 17 | {605B8AE1-834A-459B-9461-7BA72D0212BA}.Debug|x86.Build.0 = Debug|x86 18 | {605B8AE1-834A-459B-9461-7BA72D0212BA}.Debug|x86.Deploy.0 = Debug|x86 19 | {605B8AE1-834A-459B-9461-7BA72D0212BA}.Release|x86.ActiveCfg = Release|x86 20 | {605B8AE1-834A-459B-9461-7BA72D0212BA}.Release|x86.Build.0 = Release|x86 21 | {EAC9410A-0903-431D-87ED-223BFB8653C4}.Debug|x86.ActiveCfg = Debug|x86 22 | {EAC9410A-0903-431D-87ED-223BFB8653C4}.Debug|x86.Build.0 = Debug|x86 23 | {EAC9410A-0903-431D-87ED-223BFB8653C4}.Debug|x86.Deploy.0 = Debug|x86 24 | {EAC9410A-0903-431D-87ED-223BFB8653C4}.Release|x86.ActiveCfg = Release|x86 25 | {EAC9410A-0903-431D-87ED-223BFB8653C4}.Release|x86.Build.0 = Release|x86 26 | EndGlobalSection 27 | GlobalSection(SolutionProperties) = preSolution 28 | HideSolutionNode = FALSE 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /BaiduPCS_NET/BaiduPCS_NET.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | x86 7 | {605B8AE1-834A-459B-9461-7BA72D0212BA} 8 | Library 9 | Properties 10 | BaiduPCS_NET 11 | BaiduPCS_NET 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | bin\Debug\ 19 | DEBUG;TRACE 20 | full 21 | x86 22 | prompt 23 | MinimumRecommendedRules.ruleset 24 | 25 | 26 | bin\Release\ 27 | TRACE 28 | true 29 | pdbonly 30 | x86 31 | prompt 32 | MinimumRecommendedRules.ruleset 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 73 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Core/Delegates.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET 5 | { 6 | #region Delegates 7 | 8 | /// 9 | /// 当需要输入验证码时触发。 10 | /// 11 | /// 验证码图片 12 | /// 用于接收验证码字符 13 | /// 14 | /// 返回验证码是否正确输入。true - 表示正确输入;false - 表示未输入。当返回 false 时,将中断登录进程。 15 | public delegate bool GetCaptchaFunction(BaiduPCS sender, byte[] imgBytes, out string captcha, object userdata); 16 | 17 | public delegate bool GetInputFunction(BaiduPCS sender, string tips, out string captcha, object userdata); 18 | 19 | /// 20 | /// 当从网络获取到数据后触发该回调。 21 | /// 22 | /// 从网络获取到的字节序 23 | /// HTTP头中的 Content-Length 的值 24 | /// 25 | /// 返回写入的数据长度,字节为单位,必须和 data.Length 相同,否则将会中断下载。 26 | public delegate uint WriteBlockFunction(BaiduPCS sender, byte[] data, uint contentlength, object userdata); 27 | 28 | /// 29 | /// 当从网络获取到全部数据后触发该回调。 30 | /// 和 OnHttpWriteFunction 的区别是,本回调是在获取到全部内容后触发, 31 | /// 而 OnHttpWriteFunction 是每获取到一节数据后便触发。 32 | /// 每个HTTP请求,OnHttpResponse 只会触发一次,而 OnHttpWriteFunction 可能触发多次。 33 | /// 34 | /// 从网络获取到的字节序 35 | /// 36 | public delegate void OnHttpResponseFunction(BaiduPCS sender, byte[] data, object userdata); 37 | 38 | /// 39 | /// 当上传或下载一节数据到网络中时,触发该回调。利用该回调可实现上传时的进度条。 40 | /// 注意:只有设定 PCS_OPTION_PROGRESS 的值为 true 后才会启用进度条。 41 | /// 42 | /// 从网络中需要下载多少字节 43 | /// 从网络中已经下载多少字节 44 | /// 需要上传多少字节 45 | /// 已经上传多少字节 46 | /// 47 | /// 返回非零值,将导致中断上传或下载 48 | public delegate int OnHttpProgressFunction(BaiduPCS sender, double dltotal, double dlnow, double ultotal, double ulnow, object userdata); 49 | 50 | /// 51 | /// 当分片上传一个文件时,需要读取分片数据时,触发该函数。 52 | /// 用于读取分片的数据 53 | /// 查看: http://curl.haxx.se/libcurl/c/CURLOPT_READFUNCTION.html 54 | /// 55 | /// 56 | /// 分片数据将读入到这里 57 | /// 每对象的大小 58 | /// 读入多少个对象数据 59 | /// 60 | /// 返回 0 表示已经到文件结尾,将停止上传。返回 NativeConst.CURL_READFUNC_ABORT 将离开停止上传,并返回上传错误;返回 NativeConst.CURL_READFUNC_PAUSE 将暂停上传。 61 | public delegate int OnReadBlockFunction(BaiduPCS sender, out byte[] buf, uint size, uint nmemb, object userdata); 62 | 63 | #endregion 64 | } 65 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Core/PcsFileInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | 5 | using BaiduPCS_NET.Native; 6 | 7 | namespace BaiduPCS_NET 8 | { 9 | public struct PcsFileInfo 10 | { 11 | public ulong fs_id; 12 | public string path; 13 | public string server_filename; 14 | public long server_ctime; 15 | public long server_mtime; 16 | public long local_ctime; 17 | public long local_mtime; 18 | public long size; 19 | public int category; 20 | public bool isdir; 21 | public bool dir_empty; 22 | public bool empty; 23 | public string md5; 24 | public string dlink; 25 | public string[] block_list; 26 | public bool ifhassubdir; 27 | public int user_flag; 28 | 29 | public PcsFileInfo(NativePcsFileInfo fi) 30 | { 31 | this.fs_id = fi.fs_id; 32 | this.path = NativeUtils.utf8_str(fi.path); 33 | this.server_filename = NativeUtils.utf8_str(fi.server_filename); 34 | this.server_ctime = fi.server_ctime; 35 | this.server_mtime = fi.server_mtime; 36 | this.local_ctime = fi.local_ctime; 37 | this.local_mtime = fi.local_mtime; 38 | this.size = fi.size; 39 | this.category = fi.category; 40 | this.isdir = fi.isdir; 41 | this.dir_empty = fi.dir_empty; 42 | this.empty = fi.empty; 43 | this.md5 = NativeUtils.utf8_str(fi.md5); 44 | this.dlink = NativeUtils.utf8_str(fi.dlink); 45 | this.block_list = null; 46 | if (fi.block_list != IntPtr.Zero) 47 | { 48 | List list = new List(); 49 | for (int i = 0; ; i++) 50 | { 51 | IntPtr p = Marshal.ReadIntPtr(fi.block_list, i * Marshal.SizeOf(typeof(IntPtr))); 52 | if (p != IntPtr.Zero) 53 | { 54 | list.Add(NativeUtils.utf8_str(p)); 55 | } 56 | else 57 | { 58 | break; 59 | } 60 | } 61 | this.block_list = list.ToArray(); 62 | } 63 | this.ifhassubdir = fi.ifhassubdir; 64 | this.user_flag = fi.user_flag; 65 | } 66 | 67 | public bool IsEmpty 68 | { 69 | get { return this.fs_id == 0; } 70 | } 71 | 72 | public string block_list_str 73 | { 74 | get 75 | { 76 | System.Text.StringBuilder sb = new System.Text.StringBuilder(); 77 | if (block_list != null) 78 | { 79 | foreach (string s in block_list) 80 | { 81 | if (sb.Length > 0) sb.Append(", "); 82 | sb.Append("\"" + s + "\""); 83 | } 84 | } 85 | return "[ " + sb.ToString() + " ]"; 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Core/PcsOption.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPCS_NET 4 | { 5 | public enum PcsOption 6 | { 7 | PCS_OPTION_END = 0, 8 | 9 | /// 10 | /// 值为以0结尾的C格式字符串 11 | /// 12 | PCS_OPTION_USERNAME, 13 | 14 | /// 15 | /// 值为以0结尾的C格式字符串 16 | /// 17 | PCS_OPTION_PASSWORD, 18 | 19 | /// 20 | /// 值为PcsGetCaptcha类型的函数 21 | /// 22 | PCS_OPTION_CAPTCHA_FUNCTION, 23 | 24 | /// 25 | /// Pcs本身不使用该值,仅原样传递到PcsGetCaptcha函数中 26 | /// 27 | PCS_OPTION_CAPTCHA_FUNCTION_DATA, 28 | 29 | PCS_OPTION_INPUT_FUNCTION, 30 | 31 | PCS_OPTION_INPUT_FUNCTION_DATA, 32 | 33 | /// 34 | /// 值为PcsHttpWriteFunction类型的函数 35 | /// 36 | PCS_OPTION_DOWNLOAD_WRITE_FUNCTION, 37 | 38 | /// 39 | /// Pcs本身不使用该值,仅原样传递到PcsHttpWriteFunction函数中 40 | /// 41 | PCS_OPTION_DOWNLOAD_WRITE_FUNCTION_DATA, 42 | 43 | /// 44 | /// 值为PcsHttpResponseFunction类型的函数 45 | /// 46 | PCS_OPTION_HTTP_RESPONSE_FUNCTION, 47 | 48 | /// 49 | /// Pcs本身不使用该值,仅原样传递到PcsHttpResponseFunction函数中 50 | /// 51 | PCS_OPTION_HTTP_RESPONSE_FUNCTION_DATE, 52 | 53 | /// 54 | /// 值为PcsHttpProgressCallback类型的函数 55 | /// 56 | PCS_OPTION_PROGRESS_FUNCTION, 57 | 58 | /// 59 | /// Pcs本身不使用该值,仅原样传递到PcsHttpProgressCallback函数中 60 | /// 61 | PCS_OPTION_PROGRESS_FUNCTION_DATE, 62 | 63 | /// 64 | /// 设置是否启用下载或上传进度,值为PcsBool类型 65 | /// 66 | PCS_OPTION_PROGRESS, 67 | 68 | /// 69 | /// 设置USAGE,值为char类型指针 70 | /// 71 | PCS_OPTION_USAGE, 72 | 73 | /// 74 | /// 设置整个请求的超时时间,值为long类型 75 | /// 76 | PCS_OPTION_TIMEOUT, 77 | 78 | /// 79 | /// 设置连接前的等待时间,值为long类型 80 | /// 81 | PCS_OPTION_CONNECTTIMEOUT, 82 | 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Core/PcsPanApiRes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPCS_NET 4 | { 5 | public struct PcsPanApiRes 6 | { 7 | public int error; 8 | public PcsPanApiResInfo[] info_list; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Core/PcsPanApiResInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | using BaiduPCS_NET.Native; 5 | 6 | namespace BaiduPCS_NET 7 | { 8 | /*网盘API返回数据格式*/ 9 | public struct PcsPanApiResInfo 10 | { 11 | public string path; 12 | public int error; 13 | 14 | public PcsPanApiResInfo(NativePcsPanApiResInfo fi) 15 | { 16 | this.path = NativeUtils.utf8_str(fi.path); 17 | this.error = fi.error; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Core/PcsRes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPCS_NET 4 | { 5 | public enum PcsRes 6 | { 7 | PCS_NONE = -1, 8 | PCS_OK = 0, 9 | PCS_FAIL, 10 | PCS_LOGIN, 11 | PCS_NOT_LOGIN, 12 | PCS_UNKNOWN_OPT, 13 | PCS_NO_BDSTOKEN, 14 | PCS_NETWORK_ERROR, 15 | PCS_WRONG_RESPONSE, 16 | PCS_NO_CAPTCHA_FUNC, 17 | PCS_GET_CAPTCHA_FAIL, 18 | PCS_ALLOC_MEMORY, 19 | PCS_BUILD_POST_DATA, 20 | PCS_BUILD_URL, 21 | PCS_NO_LIST, 22 | PCS_CREATE_OBJ, 23 | PCS_NOT_EXIST, 24 | PCS_CLONE_OBJ, 25 | PCS_WRONG_ARGS, 26 | 27 | 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Core/SPair.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPCS_NET 4 | { 5 | /// 6 | /// 字符串对 7 | /// 8 | public struct SPair 9 | { 10 | /// 11 | /// 旧 12 | /// 13 | public string str1; 14 | 15 | /// 16 | /// 新 17 | /// 18 | public string str2; 19 | 20 | public SPair(string str1, string str2) 21 | { 22 | this.str1 = str1; 23 | this.str2 = str2; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativeConst.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPCS_NET.Native 4 | { 5 | public static class NativeConst 6 | { 7 | /// 8 | /// 本地代码中的 true 9 | /// 10 | public const byte True = 1; 11 | 12 | /// 13 | /// 本地代码中的 false 14 | /// 15 | public const byte False = 0; 16 | 17 | /// 18 | /// This is a return code for the read callback that, when returned, will 19 | /// signal libcurl to immediately abort the current transfer. 20 | /// Used by OnReadSliceFunction and NativePcsReadSliceFunction. 21 | /// 22 | public const int CURL_READFUNC_ABORT = 0x10000000; 23 | 24 | /// 25 | /// This is a return code for the read callback that, when returned, will 26 | /// signal libcurl to pause sending data on the current transfer. 27 | /// Used by OnReadSliceFunction and NativePcsReadSliceFunction. 28 | /// 29 | public const int CURL_READFUNC_PAUSE = 0x10000001; 30 | 31 | /// 32 | /// 快速上传时,计算文件的前多少个字节的 MD5 值作为验证 33 | /// 34 | public const int PCS_RAPIDUPLOAD_THRESHOLD = (256 * 1024); 35 | 36 | /// 37 | /// 全为 0 的 8x8 矩阵 38 | /// 39 | public static readonly byte[] ZERO_MATRIX_8X8 = new byte[] { 40 | 0, 0, 0, 0, 0, 0, 0, 0, 41 | 0, 0, 0, 0, 0, 0, 0, 0, 42 | 0, 0, 0, 0, 0, 0, 0, 0, 43 | 0, 0, 0, 0, 0, 0, 0, 0, 44 | 0, 0, 0, 0, 0, 0, 0, 0, 45 | 0, 0, 0, 0, 0, 0, 0, 0, 46 | 0, 0, 0, 0, 0, 0, 0, 0, 47 | 0, 0, 0, 0, 0, 0, 0, 0, 48 | }; 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativeDelegates.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET.Native 5 | { 6 | #region Native Delegates 7 | 8 | /// 9 | /// 返回验证码是否成功输入。如果返回 0,则表示验证码没有输入,将中断登录进程。 10 | /// 11 | /// 验证码图片的字节序 12 | /// 验证码图片字节序的大小,以字节为单位 13 | /// 用于接收验证码字符 14 | /// captcha的最大长度 15 | /// 使用PCS_OPTION_CAPTCHA_FUNCTION_DATA选项设定的值原样传入 16 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 17 | public delegate byte NativePcsGetCaptchaFunction(IntPtr ptr, uint size, IntPtr captcha, uint captchaSize, IntPtr state); 18 | 19 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 20 | public delegate byte NativePcsInputFunction(IntPtr tips, IntPtr captcha, uint captchaSize, IntPtr state); 21 | 22 | /// 23 | /// 设定该回调后,Pcs每从网络获取到值,则调用该回调。例如下载时。 24 | /// 25 | /// 从网络获取到的字节序 26 | /// 字节序的大小,以字节为单位 27 | /// 本次请求,HTTP头中的Content-Length值 28 | /// 使用PCS_OPTION_DOWNLOAD_WRITE_FUNCTION_DATA选项设定的值原样传入 29 | /// 30 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 31 | public delegate uint NativePcsHttpWriteFunction(IntPtr ptr, uint size, uint contentlength, IntPtr userdata); 32 | 33 | /// 34 | /// 设定该回调后,Pcs每从网络获取到值,则调用该回调。 35 | /// 和PcsHttpWriteFunction的区别是,该回调是在获取到全部内容后触发, 36 | /// 而PcsHttpWriteFunction是每获取到一段字节序则触发。 37 | /// 每个HTTP请求,PcsHttpResponseFunction只会触发一次,而PcsHttpWriteFunction可能触发多次 38 | /// 39 | /// 从网络获取到的字节序 40 | /// 字节序的大小,以字节为单位 41 | /// 使用PCS_OPTION_HTTP_RESPONSE_FUNCTION_DATE选项设定的值原样传入 42 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 43 | public delegate void NativePcsHttpResponseFunction(IntPtr ptr, uint size, IntPtr state); 44 | 45 | /// 46 | /// 设定该回调后,Pcs每上传或下载一段字节序到网络中时,则调用该回调。利用该回调可实现上传时的进度条。 47 | /// 注意:只有设定PCS_OPTION_PROGRESS的值为PcsTrue后才会启用进度条 48 | /// 49 | /// 使用PCS_OPTION_PROGRESS_FUNCTION_DATE选项设定的值原样传入 50 | /// 从网络中需要下载多少字节 51 | /// 从网络中已经下载多少字节 52 | /// 需要上传多少字节 53 | /// 已经上传多少字节 54 | /// 55 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 56 | public delegate int NativePcsHttpProgressFunction(IntPtr clientp, double dltotal, double dlnow, double ultotal, double ulnow); 57 | 58 | /// 59 | /// 当分片上传一个文件时,需要读取分片数据时,触发该函数。 60 | /// 用于读取分片的数据。 61 | /// 查看: http://curl.haxx.se/libcurl/c/CURLOPT_READFUNCTION.html 62 | /// 63 | /// 分片数据将读入到这里 64 | /// 每对象的大小 65 | /// 读入多少个对象数据 66 | /// 67 | /// 返回 0 表示已经到文件结尾,将停止上传。返回 NativeMethods.CURL_READFUNC_ABORT 将离开停止上传,并返回上传错误;返回 NativeMethods.CURL_READFUNC_PAUSE 将暂停上传。 68 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 69 | public delegate int NativePcsReadBlockFunction(IntPtr buf, uint size, uint nmemb, IntPtr userdata); 70 | 71 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 72 | public delegate void NativePcsMemLeakPrintfFunction (IntPtr ptr, string filename, int line); 73 | 74 | #endregion 75 | } 76 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativePcsFileInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET.Native 5 | { 6 | /// 7 | /// 用于存储网盘中文件的元数据 8 | /// 9 | [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)] 10 | public struct NativePcsFileInfo 11 | { 12 | public ulong fs_id; 13 | public IntPtr path; 14 | public IntPtr server_filename; 15 | public long server_ctime; 16 | public long server_mtime; 17 | public long local_ctime; 18 | public long local_mtime; 19 | public long size; 20 | public int category; 21 | [MarshalAs(UnmanagedType.U1)] 22 | public bool isdir; 23 | [MarshalAs(UnmanagedType.U1)] 24 | public bool dir_empty; 25 | [MarshalAs(UnmanagedType.U1)] 26 | public bool empty; 27 | public IntPtr md5; 28 | public IntPtr dlink; 29 | public IntPtr block_list; 30 | [MarshalAs(UnmanagedType.U1)] 31 | public bool ifhassubdir; 32 | 33 | public int user_flag; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativePcsFileInfoList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET.Native 5 | { 6 | /*以链表形式存储的网盘文件元数据列表*/ 7 | [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)] 8 | public struct NativePcsFileInfoList 9 | { 10 | public int count; 11 | public IntPtr link; 12 | public IntPtr link_tail; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativePcsFileInfoListItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET.Native 5 | { 6 | /*网盘中文件元数据链表的单个节点*/ 7 | [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)] 8 | public struct NativePcsFileInfoListItem 9 | { 10 | public IntPtr info; 11 | public IntPtr prev; 12 | public IntPtr next; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativePcsPanApiRes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET.Native 5 | { 6 | [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)] 7 | public struct NativePcsPanApiRes 8 | { 9 | public int error; 10 | public IntPtr info_list; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativePcsPanApiResInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET 5 | { 6 | /*网盘API返回数据格式*/ 7 | [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)] 8 | public struct NativePcsPanApiResInfo 9 | { 10 | public IntPtr path; 11 | public int error; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativePcsPanApiResInfoList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET.Native 5 | { 6 | [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)] 7 | public struct NativePcsPanApiResInfoList 8 | { 9 | public NativePcsPanApiResInfo info; 10 | public IntPtr next; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativePcsSList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET.Native 5 | { 6 | /* 定义了字符串列表。列表以链表形式存储。 */ 7 | [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)] 8 | public struct NativePcsSList 9 | { 10 | public IntPtr str; 11 | public IntPtr next; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Native/NativePcsSList2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace BaiduPCS_NET.Native 5 | { 6 | [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)] 7 | public struct NativePcsSList2 8 | { 9 | public IntPtr str1; 10 | public IntPtr str2; 11 | public IntPtr next; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BaiduPCS_NET/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BaiduPCS_NET")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BaiduPCS_NET")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7c97a39e-a144-4d82-96f5-5721a3740d89")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.6.0")] 36 | [assembly: AssemblyFileVersion("1.0.6.0")] 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Gang Zhuo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BaiduPCS_NET 2 | 百度网盘下载和上传工具。BaiduPCS 项目的 .net 4.0 封装。 See https://github.com/GangZhuo/BaiduPCS . 3 | 4 | 此项目还在开发中,可能存在 BUG 和不稳定,请过段时间再来。 5 | 6 | 功能: 7 | * 图形界面, 8 | * 多线程上传和下载, 9 | * 断点续传(上传和下载都支持), 10 | * 上传目录, 11 | * 下载目录。 12 | 13 | 注意: 14 | * 不支持回收站, 15 | * 以点开头的文件,上传后会自动去掉文件名的点号, 16 | * 上传时,已存在的文件名将会自动加上日期, 17 | * 下载时,本地文件已经存在时,将会自动覆盖文件(无任何提示)。 18 | * 上传大文件后,Meta Information 窗口中显示的 md5 值,可能不匹配(这是百度网盘 API 本身的问题)。此时重新上传将可解决这个问题(重新上传将会触发妙传,速度会很快;主要耗时在计算文件 md5 值)。 19 | 20 | ## 编译 (Windows): 21 | 1. git clone https://github.com/GangZhuo/BaiduPCS.git 22 | 2. git clone https://github.com/GangZhuo/BaiduPCS_NET.git 23 | 3. 按照 BaiduPCS 中 [编译-windows] 的说明,使 BaiduPCS 能够编译通过 24 | 4. 分别复制 BaiduPCS 中编译的 BaiduPCS.dll 文件到 Sample_0_FileExplorer 25 | 项目的 bin\Debug 和 bin\Release 目录下。 26 | 4. 打开 BaiduPCS_NET 目录下的 BaiduPCS_NET.sln,执行编译。 27 | 28 | ## 使用 29 | * 1. 下载:软件中鼠标选中需要下载的文件或目录(可多选),然后右击,在弹出的菜单中选择 "Download",然后选择本地目录。 30 | * 2. 上传:软件中打开上传的目标目录,在空白处右击,在弹出的菜单中选择 "Upload file" 或者 "Upload Directory"。 31 | * 3. 无论是上传还是下载必须启动工作线程,可点击历史队列窗口中顶部的图标启动工作进程。 32 | 33 | #### 下载 .net 4.0 预编译文件: [BaiduCloudDisk Releases] 。 34 | ![Main Window](https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/master/Sample/Sample_0_FileExplorer/main-window.png) 35 | ![History Window](https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/master/Sample/Sample_0_FileExplorer/history-window.png) 36 | 37 | [BaiduPCS]: https://github.com/GangZhuo/BaiduPCS 38 | [BaiduCloudDisk Releases]: https://github.com/GangZhuo/BaiduPCS_NET/releases 39 | [编译-windows]: https://github.com/GangZhuo/BaiduPCS/blob/master/README.md#编译-windows 40 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Common/AnonymousFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public delegate void AnonymousFunction(); 6 | } 7 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Common/AppSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml; 3 | using System.IO; 4 | using System.Text; 5 | 6 | namespace FileExplorer 7 | { 8 | public static class AppSettings 9 | { 10 | public static string SettingsFileName { get; set; } 11 | 12 | /// 13 | /// 获取或设置程序启动的时候,是否自动启动上传和下载线程 14 | /// 15 | public static bool ResumeDownloadAndUploadOnStartup { get; set; } 16 | 17 | /// 18 | /// 获取或设置下载时,允许的最大线程数 19 | /// 20 | public static int DownloadMaxThreadCount { get; set; } 21 | 22 | /// 23 | /// 获取或设置是否自动决定下载时使用的线程数 24 | /// 25 | public static bool AutomaticDownloadMaxThreadCount { get; set; } 26 | 27 | /// 28 | /// 获取或设置当下载失败时,是否自动重试 29 | /// 30 | public static bool RetryWhenDownloadFailed { get; set; } 31 | 32 | /// 33 | /// 获取或设置下载时的最小分片大小 34 | /// 35 | public static int MinDownloasSliceSize { get; set; } 36 | 37 | /// 38 | /// 获取或设置上传时,允许的最大线程数 39 | /// 40 | public static int UploadMaxThreadCount { get; set; } 41 | 42 | /// 43 | /// 获取或设置是否自动决定上传时使用的线程数 44 | /// 45 | public static bool AutomaticUploadMaxThreadCount { get; set; } 46 | 47 | /// 48 | /// 获取或设置当上传失败时,是否自动重试 49 | /// 50 | public static bool RetryWhenUploadFailed { get; set; } 51 | 52 | /// 53 | /// 上传时,覆写已经存在的文件 54 | /// 55 | public static bool OverWriteWhenUploadFile { get; set; } 56 | 57 | /// 58 | /// 磁盘缓存大小 59 | /// 60 | public static long MaxCacheSize { get; set; } 61 | 62 | public static bool Restore() 63 | { 64 | string filename = SettingsFileName; 65 | return RestoreFrom(filename); 66 | } 67 | 68 | public static bool RestoreFrom(string filename) 69 | { 70 | if (!File.Exists(filename)) 71 | return false; 72 | using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) 73 | { 74 | using (TextReader reader = new StreamReader(fs, true)) 75 | { 76 | return RestoreFrom(reader); 77 | } 78 | } 79 | } 80 | 81 | public static bool RestoreFrom(TextReader reader) 82 | { 83 | Type t = typeof(AppSettings); 84 | XmlDocument xml = new XmlDocument(); 85 | xml.Load(reader); 86 | XmlNodeList nodes = xml.SelectNodes("/items/item"); 87 | foreach (XmlNode n in nodes) 88 | { 89 | string name = n.Attributes["name"].Value; 90 | string value = n.Attributes["value"].Value; 91 | switch(name) 92 | { 93 | case "ResumeDownloadAndUploadOnStartup": 94 | ResumeDownloadAndUploadOnStartup = Convert.ToBoolean(value); 95 | break; 96 | 97 | case "DownloadMaxThreadCount": 98 | DownloadMaxThreadCount = Convert.ToInt32(value); 99 | break; 100 | case "AutomaticDownloadMaxThreadCount": 101 | AutomaticDownloadMaxThreadCount = Convert.ToBoolean(value); 102 | break; 103 | case "RetryWhenDownloadFailed": 104 | RetryWhenDownloadFailed = Convert.ToBoolean(value); 105 | break; 106 | case "MinDownloasSliceSize": 107 | MinDownloasSliceSize = Convert.ToInt32(value); 108 | break; 109 | 110 | case "UploadMaxThreadCount": 111 | UploadMaxThreadCount = Convert.ToInt32(value); 112 | break; 113 | case "AutomaticUploadMaxThreadCount": 114 | AutomaticUploadMaxThreadCount = Convert.ToBoolean(value); 115 | break; 116 | case "RetryWhenUploadFailed": 117 | RetryWhenUploadFailed = Convert.ToBoolean(value); 118 | break; 119 | case "OverWriteWhenUploadFile": 120 | OverWriteWhenUploadFile = Convert.ToBoolean(value); 121 | break; 122 | case "MaxCacheSize": 123 | MaxCacheSize = Convert.ToInt64(value); 124 | break; 125 | 126 | } 127 | } 128 | return true; 129 | } 130 | 131 | public static bool Save() 132 | { 133 | string filename = SettingsFileName; 134 | return SaveTo(filename); 135 | } 136 | 137 | public static bool SaveTo(string filename) 138 | { 139 | string dir = System.IO.Path.GetDirectoryName(filename); 140 | if (!System.IO.Directory.Exists(dir)) 141 | System.IO.Directory.CreateDirectory(dir); 142 | using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write)) 143 | { 144 | return SaveTo(fs); 145 | } 146 | } 147 | 148 | public static bool SaveTo(Stream stream) 149 | { 150 | XmlWriterSettings xws = new XmlWriterSettings(); 151 | xws.Encoding = Encoding.UTF8; 152 | xws.Indent = true; 153 | using (XmlWriter writer = XmlWriter.Create(stream, xws)) 154 | { 155 | writer.WriteStartDocument(); 156 | writer.WriteStartElement("items"); 157 | 158 | #region 159 | 160 | WriteItem(writer, "ResumeDownloadAndUploadOnStartup", ResumeDownloadAndUploadOnStartup.ToString()); 161 | 162 | WriteItem(writer, "DownloadMaxThreadCount", DownloadMaxThreadCount.ToString()); 163 | WriteItem(writer, "AutomaticDownloadMaxThreadCount", AutomaticDownloadMaxThreadCount.ToString()); 164 | WriteItem(writer, "RetryWhenDownloadFailed", RetryWhenDownloadFailed.ToString()); 165 | WriteItem(writer, "MinDownloasSliceSize", MinDownloasSliceSize.ToString()); 166 | 167 | WriteItem(writer, "UploadMaxThreadCount", UploadMaxThreadCount.ToString()); 168 | WriteItem(writer, "AutomaticUploadMaxThreadCount", AutomaticUploadMaxThreadCount.ToString()); 169 | WriteItem(writer, "RetryWhenUploadFailed", RetryWhenUploadFailed.ToString()); 170 | WriteItem(writer, "OverWriteWhenUploadFile", OverWriteWhenUploadFile.ToString()); 171 | WriteItem(writer, "MaxCacheSize", MaxCacheSize.ToString()); 172 | 173 | #endregion 174 | 175 | writer.WriteEndElement(); 176 | writer.WriteEndDocument(); 177 | } 178 | return true; 179 | } 180 | 181 | private static void WriteItem(XmlWriter writer, string name, string value) 182 | { 183 | writer.WriteStartElement("item"); 184 | writer.WriteStartAttribute("name"); 185 | writer.WriteString(name); 186 | writer.WriteEndAttribute(); 187 | writer.WriteStartAttribute("value"); 188 | writer.WriteString(value); 189 | writer.WriteEndAttribute(); 190 | writer.WriteEndElement(); 191 | } 192 | 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Common/SystemIcon.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using Microsoft.Win32; 8 | using System.Runtime.InteropServices; 9 | 10 | using BaiduPCS_NET; 11 | 12 | namespace FileExplorer 13 | { 14 | class SystemIcon 15 | { 16 | private static Hashtable cache = new Hashtable(); 17 | 18 | public static Icon GetFolderIcon(bool isLarge) 19 | { 20 | string key = "Folder_" + isLarge; 21 | if (cache.ContainsKey(key)) 22 | return (Icon)cache[key]; 23 | string regIconString = null; 24 | string systemDirectory = Environment.SystemDirectory + "\\"; 25 | //直接指定为文件夹图标 26 | regIconString = systemDirectory + "shell32.dll,3"; 27 | string[] fileIcon = regIconString.Split(new char[] { ',' }); 28 | Icon resultIcon = null; 29 | try 30 | { 31 | //调用API方法读取图标 32 | int[] phiconLarge = new int[1]; 33 | int[] phiconSmall = new int[1]; 34 | uint count = Win32.ExtractIconEx(fileIcon[0], Int32.Parse(fileIcon[1]), phiconLarge, phiconSmall, 1); 35 | IntPtr IconHnd = new IntPtr(isLarge ? phiconLarge[0] : phiconSmall[0]); 36 | resultIcon = Icon.FromHandle(IconHnd); 37 | } 38 | catch { } 39 | if (resultIcon != null) 40 | cache.Add(key, resultIcon); 41 | return resultIcon; 42 | } 43 | 44 | /// 45 | /// 给出文件扩展名(.*),返回相应图标 46 | /// 47 | /// 48 | /// 49 | /// 50 | public static Icon GetIcon(PcsFileInfo fileInfo, bool isLarge) 51 | { 52 | if (fileInfo.IsEmpty || string.IsNullOrEmpty(fileInfo.server_filename)) 53 | return GetUnknowTypeIcon(isLarge); 54 | 55 | if (fileInfo.isdir) 56 | return GetFolderIcon(isLarge); 57 | 58 | string ext = Path.GetExtension(fileInfo.server_filename); 59 | if (string.IsNullOrEmpty(ext)) 60 | return GetUnknowTypeIcon(isLarge); 61 | 62 | string key = "EXT_" + ext + "_" + isLarge; 63 | if (cache.ContainsKey(key)) 64 | return (Icon)cache[key]; 65 | 66 | RegistryKey regVersion = null; 67 | string regFileType = null; 68 | string regIconString = null; 69 | string systemDirectory = Environment.SystemDirectory + "\\"; 70 | 71 | try 72 | { 73 | //读系统注册表中文件类型信息 74 | regVersion = Registry.ClassesRoot.OpenSubKey(ext, true); 75 | if (regVersion != null) 76 | { 77 | regFileType = regVersion.GetValue("") as string; 78 | regVersion.Close(); 79 | regVersion = Registry.ClassesRoot.OpenSubKey(regFileType + @"\DefaultIcon", true); 80 | if (regVersion != null) 81 | { 82 | regIconString = regVersion.GetValue("") as string; 83 | regVersion.Close(); 84 | } 85 | } 86 | } 87 | catch { } 88 | 89 | Icon resultIcon = GetIcon(regIconString, isLarge); 90 | if (resultIcon != null) 91 | { 92 | cache.Add(key, resultIcon); 93 | return resultIcon; 94 | } 95 | 96 | //后缀不是 ".exe", 返回未知文件类型的图标 97 | if (!string.Equals(ext, ".exe", StringComparison.InvariantCultureIgnoreCase)) 98 | return GetUnknowTypeIcon(isLarge); 99 | 100 | return GetDefaultExeTypeIcon(isLarge); 101 | } 102 | 103 | /// 104 | /// 获取未知文件类型的图标 105 | /// 106 | /// 107 | /// 108 | public static Icon GetUnknowTypeIcon(bool isLarge) 109 | { 110 | string key = "Unknow_" + isLarge; 111 | if (cache.ContainsKey(key)) 112 | return (Icon)cache[key]; 113 | string systemDirectory = Environment.SystemDirectory + "\\"; 114 | Icon resultIcon = GetIcon(systemDirectory + "shell32.dll,0", isLarge); // 返回未知文件类型的图标 115 | if (resultIcon != null) 116 | cache.Add(key, resultIcon); 117 | return resultIcon; 118 | } 119 | 120 | /// 121 | /// 返回可执行文件的通用图标 122 | /// 123 | /// 124 | /// 125 | public static Icon GetDefaultExeTypeIcon(bool isLarge) 126 | { 127 | string key = "exe_" + isLarge; 128 | if (cache.ContainsKey(key)) 129 | return (Icon)cache[key]; 130 | string systemDirectory = Environment.SystemDirectory + "\\"; 131 | Icon resultIcon = GetIcon(systemDirectory + "shell32.dll,2", isLarge); // 返回未知文件类型的图标 132 | if (resultIcon != null) 133 | cache.Add(key, resultIcon); 134 | return resultIcon; 135 | } 136 | 137 | /// 138 | /// 根据注册表项返回图标 139 | /// 140 | /// 141 | /// 142 | /// 143 | private static Icon GetIcon(string regIconString, bool isLarge) 144 | { 145 | if (string.IsNullOrEmpty(regIconString)) 146 | return null; 147 | string[] fileIcon = regIconString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); 148 | if (fileIcon.Length != 2) 149 | return null; 150 | Icon resultIcon = null; 151 | try 152 | { 153 | //调用API方法读取图标 154 | int[] phiconLarge = new int[1]; 155 | int[] phiconSmall = new int[1]; 156 | uint count = Win32.ExtractIconEx(fileIcon[0], Int32.Parse(fileIcon[1]), phiconLarge, phiconSmall, 1); 157 | if (count > 0) 158 | { 159 | IntPtr IconHnd = new IntPtr(isLarge ? phiconLarge[0] : phiconSmall[0]); 160 | resultIcon = Icon.FromHandle(IconHnd); 161 | } 162 | } 163 | catch { } 164 | return resultIcon; 165 | } 166 | } 167 | 168 | [StructLayout(LayoutKind.Sequential)] 169 | public struct SHFILEINFO 170 | { 171 | public IntPtr hIcon; 172 | public IntPtr iIcon; 173 | public uint dwAttributes; 174 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] 175 | public string szDisplayName; 176 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] 177 | public string szTypeName; 178 | }; 179 | 180 | /// 181 | /// 定义调用的API方法 182 | /// 183 | class Win32 184 | { 185 | public const uint SHGFI_ICON = 0x100; 186 | public const uint SHGFI_LARGEICON = 0x0; // 'Large icon 187 | public const uint SHGFI_SMALLICON = 0x1; // 'Small icon 188 | 189 | [DllImport("shell32.dll")] 190 | public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags); 191 | [DllImport("shell32.dll")] 192 | public static extern uint ExtractIconEx(string lpszFile, int nIconIndex, int[] phiconLarge, int[] phiconSmall, uint nIcons); 193 | 194 | } 195 | 196 | } 197 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Common/Utils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Management; 3 | using System.Security.Cryptography; 4 | using System.Text; 5 | 6 | namespace FileExplorer 7 | { 8 | public static class Utils 9 | { 10 | 11 | public const int KB = 1024; 12 | public const int MB = 1024 * KB; 13 | public const int GB = 1024 * MB; 14 | 15 | /// 16 | /// Unix时间戳的开始时间 17 | /// 18 | public static DateTime UST = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); 19 | 20 | public static long UnixTimeStamp(DateTime dt) 21 | { 22 | TimeSpan ts = dt.ToUniversalTime() - UST; 23 | return (long)ts.TotalSeconds; 24 | } 25 | 26 | public static DateTime FromUnixTimeStamp(long timestamp) 27 | { 28 | DateTime dt = UST.AddSeconds(timestamp); 29 | return dt; 30 | } 31 | 32 | public static string md5(string input) 33 | { 34 | using (MD5 md5Hash = MD5.Create()) 35 | { 36 | // Convert the input string to a byte array and compute the hash. 37 | byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input)); 38 | 39 | // Create a new Stringbuilder to collect the bytes 40 | // and create a string. 41 | StringBuilder sBuilder = new StringBuilder(); 42 | 43 | // Loop through each byte of the hashed data 44 | // and format each one as a hexadecimal string. 45 | for (int i = 0; i < data.Length; i++) 46 | { 47 | sBuilder.Append(data[i].ToString("x2")); 48 | } 49 | 50 | // Return the hexadecimal string. 51 | return sBuilder.ToString(); 52 | } 53 | } 54 | 55 | /// 56 | /// 格式化文件大小为人类可读的格式 57 | /// 58 | /// 59 | /// 60 | public static string HumanReadableSize(long size) 61 | { 62 | //B, KB, MB, or GB 63 | if (size >= GB) 64 | { 65 | double f = (double)size / (double)GB; 66 | string scalar = f.ToString("F2"); 67 | if (scalar.EndsWith(".00")) 68 | scalar = scalar.Substring(0, scalar.Length - 3); 69 | return scalar + "GB"; 70 | } 71 | else if (size >= MB) 72 | { 73 | double f = (double)size / (double)MB; 74 | string scalar = f.ToString("F2"); 75 | if (scalar.EndsWith(".00")) 76 | scalar = scalar.Substring(0, scalar.Length - 3); 77 | return scalar + "MB"; 78 | } 79 | else if (size >= KB) 80 | { 81 | double f = (double)size / (double)KB; 82 | string scalar = f.ToString("F2"); 83 | if (scalar.EndsWith(".00")) 84 | scalar = scalar.Substring(0, scalar.Length - 3); 85 | return scalar + "KB"; 86 | } 87 | else 88 | { 89 | return size.ToString() + "B"; 90 | } 91 | } 92 | 93 | public static string LeftTime(long leftSize, long speed) 94 | { 95 | // 计算剩余时间 96 | string s; 97 | int second; 98 | if (speed == 0) 99 | return ""; 100 | second = (int)(leftSize / speed); 101 | TimeSpan ts = new TimeSpan(0, 0, second); 102 | s = ""; 103 | if (ts.TotalDays > 1) 104 | s += ((int)ts.TotalDays).ToString() + "day(s) "; 105 | if (ts.TotalHours > 1) 106 | s += ((int)ts.TotalHours).ToString().PadLeft(2, '0') + ":"; 107 | else 108 | s += "00:"; 109 | if (ts.TotalMinutes > 1) 110 | s += ((int)ts.TotalMinutes).ToString().PadLeft(2, '0') + ":"; 111 | else 112 | s += "00:"; 113 | if (ts.TotalSeconds > 1) 114 | s += ((int)ts.TotalSeconds).ToString().PadLeft(2, '0'); 115 | else 116 | s += "00"; 117 | return s; 118 | } 119 | 120 | /// 121 | /// 获取 CPU 属性参数 122 | /// 123 | /// 返回 CPU 属性参数 124 | public static string GetCPUProperties() 125 | { 126 | // Get the WMI class 127 | ManagementClass c = new ManagementClass(new ManagementPath("Win32_Processor")); 128 | // Get the properties in the class 129 | ManagementObjectCollection moc = c.GetInstances(); 130 | 131 | System.Text.StringBuilder sb = new System.Text.StringBuilder(); 132 | // display the properties 133 | sb.AppendLine("Property Names: "); 134 | sb.AppendLine("================="); 135 | foreach (ManagementObject mo in moc) 136 | { 137 | PropertyDataCollection properties = mo.Properties; 138 | //获取内核数代码 139 | sb.AppendLine("物理内核数:" + properties["NumberOfCores"].Value); 140 | sb.AppendLine("逻辑内核数:" + properties["NumberOfLogicalProcessors"].Value); 141 | //其他属性获取代码 142 | foreach (PropertyData property in properties) 143 | { 144 | sb.AppendLine(property.Name + ":" + property.Value); 145 | } 146 | } 147 | string s = sb.ToString(); 148 | return s; 149 | } 150 | 151 | /// 152 | /// 获取 CPU 逻辑内核数 153 | /// 154 | /// 返回 CPU 逻辑内核数 155 | public static int GetLogicProcessorCount() 156 | { 157 | int coreCount; 158 | return GetLogicProcessorCount(out coreCount); 159 | } 160 | 161 | /// 162 | /// 获取 CPU 逻辑内核数 163 | /// 164 | /// 函数执行成功后,此变量被设置为物理内核数 165 | /// 返回 CPU 逻辑内核数 166 | public static int GetLogicProcessorCount(out int coreCount) 167 | { 168 | int logicCount = 0; 169 | coreCount = 0; 170 | // Get the WMI class 171 | ManagementClass c = new ManagementClass(new ManagementPath("Win32_Processor")); 172 | // Get the properties in the class 173 | ManagementObjectCollection moc = c.GetInstances(); 174 | 175 | foreach (ManagementObject mo in moc) 176 | { 177 | PropertyDataCollection properties = mo.Properties; 178 | //获取内核数 179 | logicCount = Convert.ToInt32(properties["NumberOfLogicalProcessors"].Value); 180 | coreCount = Convert.ToInt32(properties["NumberOfCores"].Value); 181 | break; 182 | } 183 | return logicCount; 184 | } 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/BigFileHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.IO.MemoryMappedFiles; 4 | 5 | namespace FileExplorer 6 | { 7 | public class BigFileHelper : IDisposable, IBigFileHelper 8 | { 9 | public string FileName { get; private set; } 10 | private MemoryMappedFile mmf; 11 | private long fileSize; 12 | 13 | public BigFileHelper(string filename, long filesize) 14 | { 15 | FileName = filename; 16 | this.fileSize = filesize; 17 | mmf = MemoryMappedFile.CreateFromFile(FileName, FileMode.Open, Utils.md5(FileName), filesize, MemoryMappedFileAccess.ReadWrite); //映射文件到内存 18 | } 19 | 20 | ~BigFileHelper() 21 | { 22 | Disposing(false); 23 | } 24 | 25 | public void Dispose() 26 | { 27 | Disposing(true); 28 | GC.SuppressFinalize(this); 29 | } 30 | 31 | protected void Disposing(bool disposing) 32 | { 33 | if(disposing) 34 | { 35 | if (mmf != null) 36 | { 37 | mmf.Dispose(); 38 | mmf = null; 39 | } 40 | } 41 | } 42 | 43 | public void Update(long position, byte[] array, int offset, int count) 44 | { 45 | using (MemoryMappedViewAccessor accessor = mmf.CreateViewAccessor(position, count)) 46 | { 47 | accessor.WriteArray(0, array, offset, count); 48 | } 49 | } 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/Cache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace FileExplorer 7 | { 8 | public class Cache 9 | { 10 | public long TotalSize { get; set; } 11 | 12 | public IBigFileHelper FileHelper { get; set; } 13 | 14 | public List BlockList { get; private set; } 15 | 16 | public Cache() 17 | { 18 | TotalSize = 0L; 19 | BlockList = new List(); 20 | } 21 | 22 | public void Add(long position, byte[] data, int size) 23 | { 24 | Block block = new Block(); 25 | block.Position = position; 26 | block.Data = data; 27 | block.Size = size; 28 | BlockList.Add(block); 29 | TotalSize += size; 30 | } 31 | 32 | public void Flush() 33 | { 34 | BlockList.Sort(new BlockComparer()); 35 | foreach (Block block in BlockList) 36 | { 37 | FileHelper.Update(block.Position, block.Data, 0, block.Size); 38 | } 39 | } 40 | 41 | public void Reset() 42 | { 43 | TotalSize = 0; 44 | BlockList.Clear(); 45 | } 46 | 47 | public class Block 48 | { 49 | public long Position { get; set; } 50 | 51 | public int Size { get; set; } 52 | 53 | public byte[] Data { get; set; } 54 | } 55 | 56 | public class BlockComparer : IComparer 57 | { 58 | public int Compare(Block x, Block y) 59 | { 60 | long xpos = x == null ? 0L : x.Position; 61 | long ypos = y == null ? 0L : y.Position; 62 | return xpos < ypos ? -1 : (xpos > ypos ? 1 : 0); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/CompletedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public class CompletedEventArgs : EventArgs 6 | { 7 | public bool Success { get; private set; } 8 | public bool Cancel { get; private set; } 9 | public Exception Exception { get; private set; } 10 | 11 | public CompletedEventArgs(bool success, bool cancel, Exception ex) 12 | { 13 | Success = success; 14 | Cancel = cancel; 15 | Exception = ex; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/Downloader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | using BaiduPCS_NET; 5 | 6 | namespace FileExplorer 7 | { 8 | public class Downloader : ICancellable, IProgressable 9 | { 10 | public BaiduPCS pcs { get; protected set; } 11 | public PcsFileInfo from { get; set; } 12 | public string to { get; set; } 13 | public long DoneSize { get; protected set; } 14 | public bool Success { get; protected set; } 15 | public bool IsCancelled { get; protected set; } 16 | public Exception Error { get; protected set; } 17 | public bool Downloading { get; protected set; } 18 | public object State { get; set; } 19 | 20 | public event EventHandler Completed; 21 | public event EventHandler Progress; 22 | public event EventHandler StateFileNameDecide; 23 | public event EventHandler ThreadChanged; 24 | 25 | public Downloader(BaiduPCS pcs, PcsFileInfo from, string to) 26 | { 27 | this.pcs = pcs; 28 | this.from = from; 29 | this.to = to; 30 | } 31 | 32 | public virtual void Download() 33 | { 34 | if (Downloading) 35 | throw new Exception("Can't download, since the previous download is not complete."); 36 | FileStream stream = null; 37 | DoneSize = 0; 38 | Success = false; 39 | IsCancelled = false; 40 | Error = null; 41 | Downloading = true; 42 | try 43 | { 44 | BaiduPCS pcs = this.pcs.clone(); 45 | pcs.Write += onWrite; 46 | CreateDirectory(to); 47 | stream = new FileStream(to, FileMode.Create, FileAccess.Write); 48 | pcs.WriteUserData = stream; 49 | fireThreadChanged(new ThreadCountChangedEventArgs(1, 1)); 50 | PcsRes rc = pcs.download(from.path, 0, 0, 0); 51 | if (rc == PcsRes.PCS_OK) 52 | { 53 | Success = true; 54 | IsCancelled = false; 55 | } 56 | else if (IsCancelled) 57 | { 58 | Success = false; 59 | IsCancelled = true; 60 | } 61 | else 62 | { 63 | Success = false; 64 | IsCancelled = false; 65 | if (Error == null) 66 | Error = new Exception(pcs.getError()); 67 | } 68 | } 69 | catch (Exception ex) 70 | { 71 | Success = false; 72 | IsCancelled = false; 73 | Error = ex; 74 | } 75 | if (stream != null) 76 | stream.Close(); 77 | Downloading = false; 78 | fireCompleted(new CompletedEventArgs(Success, IsCancelled, Error)); 79 | fireThreadChanged(new ThreadCountChangedEventArgs(0, 1)); 80 | } 81 | 82 | public virtual void Cancel() 83 | { 84 | IsCancelled = true; 85 | } 86 | 87 | private uint onWrite(BaiduPCS sender, byte[] data, uint contentlength, object userdata) 88 | { 89 | if (IsCancelled) 90 | return 0; 91 | try 92 | { 93 | if (data.Length > 0) 94 | { 95 | Stream stream = (Stream)userdata; 96 | stream.Write(data, 0, data.Length); 97 | } 98 | DoneSize += data.Length; 99 | ProgressEventArgs args = new ProgressEventArgs(DoneSize, from.size); 100 | fireProgress(args); 101 | if (args.Cancel) 102 | { 103 | IsCancelled = true; 104 | return 0; 105 | } 106 | return (uint)data.Length; 107 | } 108 | catch (Exception ex) 109 | { 110 | Error = ex; 111 | } 112 | return 0; 113 | } 114 | 115 | protected virtual void CreateDirectory(string filename) 116 | { 117 | string dir = Path.GetDirectoryName(filename); 118 | if (!Directory.Exists(dir)) 119 | Directory.CreateDirectory(dir); 120 | } 121 | 122 | protected virtual void fireProgress(ProgressEventArgs args) 123 | { 124 | if (Progress != null) 125 | Progress(this, args); 126 | } 127 | 128 | protected virtual void fireCompleted(CompletedEventArgs args) 129 | { 130 | if (Completed != null) 131 | Completed(this, args); 132 | } 133 | 134 | protected virtual void fireStateFileNameDecide(StateFileNameDecideEventArgs args) 135 | { 136 | if (StateFileNameDecide != null) 137 | StateFileNameDecide(this, args); 138 | } 139 | 140 | protected virtual void fireThreadChanged(ThreadCountChangedEventArgs args) 141 | { 142 | if (ThreadChanged != null) 143 | ThreadChanged(this, args); 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/IBigFileHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public interface IBigFileHelper : IDisposable 6 | { 7 | string FileName { get; } 8 | 9 | void Update(long position, byte[] array, int offset, int count); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/ICancellable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public interface ICancellable 6 | { 7 | void Cancel(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/IProgressable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public interface IProgressable 6 | { 7 | object State { get; set; } 8 | event EventHandler StateFileNameDecide; 9 | event EventHandler Progress; 10 | event EventHandler Completed; 11 | event EventHandler ThreadChanged; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/ProgressEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public class ProgressEventArgs : EventArgs 6 | { 7 | public long doneSize { get; private set; } 8 | 9 | public long totalSize { get; private set; } 10 | 11 | public bool Cancel { get; set; } 12 | 13 | public ProgressEventArgs(long doneSize, long totalSize) 14 | { 15 | this.doneSize = doneSize; 16 | this.totalSize = totalSize; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/RapidUploader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using BaiduPCS_NET; 4 | 5 | namespace FileExplorer 6 | { 7 | public class RapidUploader : Uploader 8 | { 9 | public string FileMD5 { get; private set; } 10 | 11 | public RapidUploader(BaiduPCS pcs, string from, string to) 12 | : base(pcs, from, to) 13 | { 14 | } 15 | 16 | public override void Upload() 17 | { 18 | if (Uploading) 19 | throw new Exception("Can't upload, since the previous upload is not complete."); 20 | DoneSize = 0; 21 | Success = false; 22 | IsCancelled = false; 23 | Error = null; 24 | Uploading = true; 25 | try 26 | { 27 | BaiduPCS pcs = this.pcs.clone(); 28 | string filemd5 = null; 29 | string slicemd5 = null; 30 | Result = pcs.rapid_upload(to, from, ref filemd5, ref slicemd5, IsOverWrite); 31 | FileMD5 = filemd5; 32 | if (!Result.IsEmpty) 33 | { 34 | Success = true; 35 | IsCancelled = false; 36 | } 37 | else if (IsCancelled) 38 | { 39 | Success = false; 40 | IsCancelled = true; 41 | } 42 | else 43 | { 44 | Success = false; 45 | IsCancelled = false; 46 | if (Error == null) 47 | Error = new Exception(pcs.getError()); 48 | } 49 | } 50 | catch (Exception ex) 51 | { 52 | Success = false; 53 | IsCancelled = false; 54 | Error = ex; 55 | } 56 | Uploading = false; 57 | fireCompleted(new CompletedEventArgs(Success, IsCancelled, Error)); 58 | } 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/Slice.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public class Slice 6 | { 7 | /// 8 | /// 分片索引号 9 | /// 10 | public int index { get; set; } 11 | 12 | /// 13 | /// 开始位置 14 | /// 15 | public long start { get; set; } 16 | 17 | /// 18 | /// 长度 19 | /// 20 | public long totalSize { get; set; } 21 | 22 | /// 23 | /// 已经完成的长度 24 | /// 25 | public long doneSize { get; set; } 26 | 27 | /// 28 | /// 上传成功后的分片的MD5值 29 | /// 30 | public string md5 { get; set; } 31 | 32 | /// 33 | /// 分片的状态 34 | /// 35 | public SliceStatus status { get; set; } 36 | 37 | /// 38 | /// 用户数据 39 | /// 40 | public object userdata { get; set; } 41 | 42 | /// 43 | /// 任务ID 44 | /// 45 | public long tid { get; set; } 46 | 47 | public Slice() 48 | { 49 | this.md5 = string.Empty; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/SliceHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | 6 | namespace FileExplorer 7 | { 8 | public class SliceHelper 9 | { 10 | /// 11 | /// 计算分片大小 12 | /// 13 | /// 文件大小 14 | /// 允许的最小分片大小 15 | /// 允许最多多少个分片 16 | /// 17 | public static long CalculateSliceSize(long fileSize, long minSliceSize, long maxSliceCount) 18 | { 19 | long sliceCount = 0; //分片数量 20 | 21 | // 先按照最小分片计算分片数量 22 | long sliceSize = minSliceSize; 23 | sliceCount = (int)(fileSize / sliceSize); 24 | if ((fileSize % sliceSize) != 0) 25 | sliceCount++; 26 | 27 | if(sliceCount > maxSliceCount) 28 | { 29 | sliceSize = fileSize / maxSliceCount; 30 | if ((fileSize % maxSliceCount) != 0) 31 | sliceSize++; 32 | 33 | sliceCount = (int)(fileSize / sliceSize); 34 | if ((fileSize % sliceSize) != 0) 35 | sliceCount++; 36 | } 37 | return sliceSize; 38 | } 39 | 40 | /// 41 | /// 创建分片 42 | /// 43 | /// 文件的大小 44 | /// 分片的字节大小 45 | /// 返回分片列表 46 | public static List CreateSliceList(long filesize, int sliceSize) 47 | { 48 | List slicelist = new List(); 49 | 50 | #region 开始分片 51 | 52 | long slice_count = 0; //分片数量 53 | 54 | // 先按照最小分片计算分片数量 55 | long slice_size = sliceSize; 56 | slice_count = (int)(filesize / slice_size); 57 | if ((filesize % slice_size) != 0) 58 | slice_count++; 59 | 60 | long offset = 0; 61 | for (int i = 0; i < slice_count; i++) 62 | { 63 | Slice ts = new Slice() 64 | { 65 | index = i, 66 | start = offset, 67 | totalSize = slice_size 68 | }; 69 | if (ts.start + ts.totalSize > filesize) ts.totalSize = filesize - ts.start; 70 | offset += slice_size; 71 | slicelist.Add(ts); 72 | } 73 | 74 | #endregion 75 | 76 | return slicelist; 77 | } 78 | 79 | /// 80 | /// 从分片文件中还原分片信息 81 | /// 82 | /// 上次上传时,存储的分片文件 83 | /// 拥有这些分片的 SliceOwner 对象 84 | /// 返回分片列表 85 | public static List RestoreSliceList(string slice_filename) 86 | { 87 | List list = new List(); 88 | Slice slice; 89 | using (FileStream fs = new FileStream(slice_filename, FileMode.Open, FileAccess.Read, FileShare.Read)) 90 | { 91 | using (BinaryReader br = new BinaryReader(fs)) 92 | { 93 | while (br.BaseStream.Position < br.BaseStream.Length) 94 | { 95 | slice = ReadSlice(br); 96 | list.Add(slice); 97 | } 98 | } 99 | } 100 | return list; 101 | } 102 | 103 | /// 104 | /// 保存分片数据到文件 105 | /// 106 | /// 保存分片数据到此文件中 107 | /// 待保存的分片列表 108 | public static void SaveSliceList(string filename, List list) 109 | { 110 | string dir = Path.GetDirectoryName(filename); 111 | if (!Directory.Exists(dir)) 112 | Directory.CreateDirectory(dir); 113 | using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Write)) 114 | { 115 | using (BinaryWriter br = new BinaryWriter(fs)) 116 | { 117 | foreach (Slice slice in list) 118 | { 119 | WriteSlice(br, slice); 120 | } 121 | } 122 | } 123 | } 124 | 125 | /// 126 | /// 删除分片文件 127 | /// 128 | /// 待删除的分片文件 129 | public static void DeleteSliceFile(string filename) 130 | { 131 | if (File.Exists(filename)) 132 | File.Delete(filename); // 删除分片文件 133 | } 134 | 135 | /// 136 | /// 读入一个分片 137 | /// 138 | /// 用于读入数据的流 139 | /// 140 | public static Slice ReadSlice(BinaryReader br) 141 | { 142 | byte[] bs; 143 | Slice slice = new Slice(); 144 | slice.index = br.ReadInt32(); 145 | slice.start = br.ReadInt64(); 146 | slice.totalSize = br.ReadInt64(); 147 | slice.doneSize = br.ReadInt64(); 148 | slice.status = (SliceStatus)br.ReadInt32(); 149 | int len = br.ReadInt32(); 150 | if (len > 0) 151 | { 152 | bs = br.ReadBytes(len); 153 | slice.md5 = Encoding.UTF8.GetString(bs).Trim('\0').Trim(); 154 | } 155 | return slice; 156 | } 157 | 158 | /// 159 | /// 写入一个分片 160 | /// 161 | /// 用于写入数据的流 162 | /// 待写入的分片 163 | public static void WriteSlice(BinaryWriter br, Slice slice) 164 | { 165 | byte[] bs; 166 | br.Write(slice.index); 167 | br.Write(slice.start); 168 | br.Write(slice.totalSize); 169 | br.Write(slice.doneSize); 170 | br.Write((int)slice.status); 171 | if (!string.IsNullOrEmpty(slice.md5)) 172 | { 173 | bs = Encoding.UTF8.GetBytes(slice.md5); 174 | br.Write(bs.Length); 175 | br.Write(bs); 176 | } 177 | else 178 | { 179 | br.Write((int)0); 180 | } 181 | } 182 | 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/SliceStatus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public enum SliceStatus 6 | { 7 | /// 8 | /// 等待处理 9 | /// 10 | Pending = 0, 11 | 12 | /// 13 | /// 运行中 14 | /// 15 | Running, 16 | 17 | /// 18 | /// 重试中 19 | /// 20 | Retrying, 21 | 22 | /// 23 | /// 失败 24 | /// 25 | Failed, 26 | 27 | /// 28 | /// 成功 29 | /// 30 | Successed, 31 | 32 | /// 33 | /// 取消 34 | /// 35 | Cancelled, 36 | 37 | /// 38 | /// 错误 39 | /// 40 | Error, 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/StateFileNameDecideEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public class StateFileNameDecideEventArgs : EventArgs 6 | { 7 | public string SliceFileName { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/ThreadCountChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public class ThreadCountChangedEventArgs : EventArgs 6 | { 7 | public int RunningThreadCount { get; private set; } 8 | public int TotalThreadCount { get; private set; } 9 | 10 | public ThreadCountChangedEventArgs(int running, int total) 11 | { 12 | RunningThreadCount = running; 13 | TotalThreadCount = total; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/DU/Uploader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | using BaiduPCS_NET; 5 | 6 | namespace FileExplorer 7 | { 8 | 9 | public class Uploader : ICancellable, IProgressable 10 | { 11 | public BaiduPCS pcs { get; protected set; } 12 | public string from { get; set; } 13 | public string to { get; set; } 14 | /// 15 | /// 设置或获取是否覆盖同名文件 16 | /// 17 | public bool IsOverWrite { get; set; } 18 | public long DoneSize { get; protected set; } 19 | public bool Success { get; protected set; } 20 | public bool IsCancelled { get; protected set; } 21 | public Exception Error { get; protected set; } 22 | public bool Uploading { get; protected set; } 23 | public PcsFileInfo Result { get; protected set; } 24 | public object State { get; set; } 25 | 26 | public event EventHandler Completed; 27 | public event EventHandler Progress; 28 | public event EventHandler StateFileNameDecide; 29 | public event EventHandler ThreadChanged; 30 | 31 | public Uploader(BaiduPCS pcs, string from, string to) 32 | { 33 | this.pcs = pcs; 34 | this.from = from; 35 | this.to = to; 36 | } 37 | 38 | public virtual void Upload() 39 | { 40 | if (Uploading) 41 | throw new Exception("Can't upload, since the previous upload is not complete."); 42 | DoneSize = 0; 43 | Success = false; 44 | IsCancelled = false; 45 | Error = null; 46 | Uploading = true; 47 | try 48 | { 49 | BaiduPCS pcs = this.pcs.clone(); 50 | pcs.Progress += onProgress; 51 | fireThreadChanged(new ThreadCountChangedEventArgs(1, 1)); 52 | Result = pcs.upload(to, from, IsOverWrite); 53 | if (!Result.IsEmpty) 54 | { 55 | Success = true; 56 | IsCancelled = false; 57 | } 58 | else if (IsCancelled) 59 | { 60 | Success = false; 61 | IsCancelled = true; 62 | } 63 | else 64 | { 65 | Success = false; 66 | IsCancelled = false; 67 | if (Error == null) 68 | Error = new Exception(pcs.getError()); 69 | } 70 | } 71 | catch (Exception ex) 72 | { 73 | Success = false; 74 | IsCancelled = false; 75 | Error = ex; 76 | } 77 | Uploading = false; 78 | fireCompleted(new CompletedEventArgs(Success, IsCancelled, Error)); 79 | fireThreadChanged(new ThreadCountChangedEventArgs(0, 1)); 80 | } 81 | 82 | public virtual void Cancel() 83 | { 84 | IsCancelled = true; 85 | } 86 | 87 | private int onProgress(BaiduPCS sender, double dltotal, double dlnow, double ultotal, double ulnow, object userdata) 88 | { 89 | ProgressEventArgs args = new ProgressEventArgs((long)ulnow, (long)ultotal); 90 | fireProgress(args); 91 | if (args.Cancel) 92 | { 93 | IsCancelled = true; 94 | return -1; 95 | } 96 | return 0; 97 | } 98 | 99 | protected virtual void fireProgress(ProgressEventArgs args) 100 | { 101 | if (Progress != null) 102 | Progress(this, args); 103 | } 104 | 105 | protected virtual void fireCompleted(CompletedEventArgs args) 106 | { 107 | if (Completed != null) 108 | Completed(this, args); 109 | } 110 | 111 | protected virtual void fireStateFileNameDecide(StateFileNameDecideEventArgs args) 112 | { 113 | if (StateFileNameDecide != null) 114 | StateFileNameDecide(this, args); 115 | } 116 | 117 | protected virtual void fireThreadChanged(ThreadCountChangedEventArgs args) 118 | { 119 | if (ThreadChanged != null) 120 | ThreadChanged(this, args); 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/ListViewItemComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Windows.Forms; 4 | using System.IO; 5 | using BaiduPCS_NET; 6 | 7 | namespace FileExplorer 8 | { 9 | public class ListViewItemComparer : IComparer 10 | { 11 | public enum ComparerBy 12 | { 13 | None, 14 | FileName, 15 | FileSize, 16 | FileType, 17 | FileModifyTime, 18 | } 19 | 20 | public int Column { get; set; } 21 | public ComparerBy By { get; set; } 22 | public bool Descending { get; set; } 23 | 24 | private int CompareByFileName(PcsFileInfo x, PcsFileInfo y) 25 | { 26 | if (x.isdir && y.isdir) 27 | return string.Compare(x.server_filename, y.server_filename); 28 | else if (x.isdir) 29 | return -1; 30 | else if (x.isdir) 31 | return 1; 32 | else 33 | return string.Compare(x.server_filename, y.server_filename); 34 | } 35 | 36 | private int CompareByFileSize(PcsFileInfo x, PcsFileInfo y) 37 | { 38 | if (x.isdir && y.isdir) 39 | return 0; 40 | else if (x.isdir) 41 | return -1; 42 | else if (y.isdir) 43 | return 1; 44 | else 45 | return x.size < y.size ? -1 : (x.size > y.size ? 1 : 0); 46 | } 47 | 48 | private int CompareByFileType(PcsFileInfo x, PcsFileInfo y) 49 | { 50 | if (x.isdir && y.isdir) 51 | return 0; 52 | else if (x.isdir) 53 | return -1; 54 | else if (y.isdir) 55 | return 1; 56 | else 57 | return string.Compare(Path.GetExtension(x.server_filename), Path.GetExtension(y.server_filename)); 58 | } 59 | 60 | private int CompareByFileModifyTime(PcsFileInfo x, PcsFileInfo y) 61 | { 62 | if (x.isdir && y.isdir) 63 | return 0; 64 | else if (x.isdir) 65 | return -1; 66 | else if (y.isdir) 67 | return 1; 68 | else 69 | return x.server_mtime < y.server_mtime ? -1 : (x.server_mtime > y.server_mtime ? 1 : 0); 70 | } 71 | 72 | public int Compare(object x, object y) 73 | { 74 | int r, wt = Descending ? -1 : 1; 75 | ListViewItem xitem = (ListViewItem)x; 76 | ListViewItem yitem = (ListViewItem)y; 77 | if (xitem.Tag != null && yitem.Tag != null) 78 | { 79 | if ((xitem.Tag is PcsFileInfo) && (yitem.Tag is PcsFileInfo)) 80 | { 81 | PcsFileInfo xfi = (PcsFileInfo)xitem.Tag; 82 | PcsFileInfo yfi = (PcsFileInfo)yitem.Tag; 83 | switch (By) 84 | { 85 | case ComparerBy.FileName: 86 | r = CompareByFileName(xfi, yfi); 87 | break; 88 | case ComparerBy.FileSize: 89 | r = CompareByFileSize(xfi, yfi); 90 | break; 91 | case ComparerBy.FileType: 92 | r = CompareByFileType(xfi, yfi); 93 | break; 94 | case ComparerBy.FileModifyTime: 95 | r = CompareByFileModifyTime(xfi, yfi); 96 | break; 97 | default: 98 | r = string.Compare(xitem.SubItems[Column].Text, yitem.SubItems[Column].Text); 99 | break; 100 | } 101 | return r * wt; 102 | } 103 | } 104 | 105 | return wt * string.Compare(xitem.SubItems[Column].Text, yitem.SubItems[Column].Text); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/ListViewProgress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Windows.Forms; 4 | 5 | namespace FileExplorer 6 | { 7 | public class ProgressListview : ListView 8 | { 9 | public ProgressListview() 10 | { 11 | SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); 12 | UpdateStyles(); 13 | } 14 | 15 | protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) 16 | { 17 | e.DrawDefault = true; 18 | base.OnDrawColumnHeader(e); 19 | } 20 | 21 | protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) 22 | { 23 | ListViewItem.ListViewSubItem oitem = e.Item.SubItems[e.ColumnIndex]; 24 | ProgressSubItem item = null; 25 | 26 | if (oitem is ProgressSubItem) 27 | item = (ProgressSubItem)oitem; 28 | if (item != null && item.ShowProgress && item.ProgressMaxValue > 0) 29 | { 30 | double percent = (double)item.ProgressValue / (double)item.ProgressMaxValue; 31 | if (percent > 1.0f) 32 | percent = 1.0f; 33 | Rectangle rect = item.Bounds; 34 | Graphics g = e.Graphics; 35 | 36 | //绘制进度条 37 | Rectangle progressRect = new Rectangle(rect.X + 1, rect.Y + 3, rect.Width - 2, rect.Height - 5); 38 | g.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(0x51, 0x51, 0x51)), 1), progressRect); 39 | 40 | //绘制进度 41 | int progressMaxWidth = progressRect.Width - 1; 42 | int width = (int)(progressMaxWidth * percent); 43 | if (width >= progressMaxWidth) width = progressMaxWidth; 44 | g.FillRectangle(new SolidBrush(Color.FromArgb(0xa4, 0xa3, 0xa3)), new Rectangle(progressRect.X + 1, progressRect.Y + 1, width, progressRect.Height - 1)); 45 | 46 | if(item.ShowPercentOverflowProgress) 47 | { 48 | //绘制进度百分比 49 | percent *= 100; 50 | string percentText = string.Format("{0}% ", percent.ToString("F2")); 51 | Size size = TextRenderer.MeasureText(percentText.ToString(), Font); 52 | int x = (progressRect.Width - size.Width) / 2; 53 | int y = (progressRect.Height - size.Height) / 2 + 3; 54 | if (x <= 0) x = 1; 55 | if (y <= 0) y = 1; 56 | int w = size.Width; 57 | int h = size.Height; 58 | if (w > progressRect.Width) w = progressRect.Width; 59 | if (h > progressRect.Height) h = progressRect.Height; 60 | g.DrawString(percentText, this.Font, new SolidBrush(Color.Black), new Rectangle(rect.X + x, rect.Y + y, w, h)); 61 | } 62 | } 63 | else 64 | { 65 | e.DrawDefault = true; 66 | base.OnDrawSubItem(e); 67 | } 68 | } 69 | 70 | public class ProgressSubItem : ListViewItem.ListViewSubItem 71 | { 72 | public ProgressSubItem() 73 | : base() 74 | { 75 | ShowProgress = true; 76 | ShowPercentOverflowProgress = true; 77 | ProgressValue = 0; 78 | ProgressMaxValue = 100; 79 | } 80 | 81 | public ProgressSubItem(ListViewItem owner, string text) 82 | : base(owner, text) 83 | { 84 | ShowProgress = true; 85 | ShowPercentOverflowProgress = true; 86 | ProgressValue = 0; 87 | ProgressMaxValue = 100; 88 | } 89 | 90 | public ProgressSubItem(ListViewItem owner, string text, Color foreColor, Color backColor, Font font) 91 | : base(owner, text, foreColor, backColor, font) 92 | { 93 | ShowProgress = true; 94 | ShowPercentOverflowProgress = true; 95 | ProgressValue = 0; 96 | ProgressMaxValue = 100; 97 | } 98 | 99 | public bool ShowProgress { get; set; } 100 | 101 | public bool ShowPercentOverflowProgress { get; set; } 102 | 103 | public long ProgressValue { get; set; } 104 | 105 | public long ProgressMaxValue { get; set; } 106 | 107 | public ListViewItem Owner { get; set; } 108 | } 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmCaptcha.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace FileExplorer 10 | { 11 | public partial class frmCaptcha : Form 12 | { 13 | public string Captcha 14 | { 15 | get { return textBox1.Text.Trim(); } 16 | } 17 | 18 | public frmCaptcha(byte[] imgBytes) 19 | { 20 | InitializeComponent(); 21 | 22 | using(System.IO.MemoryStream ms = new System.IO.MemoryStream(imgBytes)) 23 | { 24 | System.Drawing.Image img = System.Drawing.Image.FromStream(ms); 25 | pictureBox1.Image = img; 26 | } 27 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 28 | } 29 | 30 | private void frmCaptcha_Load(object sender, EventArgs e) 31 | { 32 | 33 | } 34 | 35 | private void button1_Click(object sender, EventArgs e) 36 | { 37 | DialogResult = System.Windows.Forms.DialogResult.OK; 38 | this.Close(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmCaptcha.designer.cs: -------------------------------------------------------------------------------- 1 | namespace FileExplorer 2 | { 3 | partial class frmCaptcha 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.textBox1 = new System.Windows.Forms.TextBox(); 34 | this.button1 = new System.Windows.Forms.Button(); 35 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 36 | this.SuspendLayout(); 37 | // 38 | // pictureBox1 39 | // 40 | this.pictureBox1.Location = new System.Drawing.Point(14, 68); 41 | this.pictureBox1.Name = "pictureBox1"; 42 | this.pictureBox1.Size = new System.Drawing.Size(100, 50); 43 | this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; 44 | this.pictureBox1.TabIndex = 0; 45 | this.pictureBox1.TabStop = false; 46 | // 47 | // label1 48 | // 49 | this.label1.AutoSize = true; 50 | this.label1.Location = new System.Drawing.Point(12, 25); 51 | this.label1.Name = "label1"; 52 | this.label1.Size = new System.Drawing.Size(50, 13); 53 | this.label1.TabIndex = 1; 54 | this.label1.Text = "Captcha:"; 55 | // 56 | // textBox1 57 | // 58 | this.textBox1.Location = new System.Drawing.Point(80, 22); 59 | this.textBox1.MaxLength = 8; 60 | this.textBox1.Name = "textBox1"; 61 | this.textBox1.Size = new System.Drawing.Size(127, 20); 62 | this.textBox1.TabIndex = 2; 63 | // 64 | // button1 65 | // 66 | this.button1.Location = new System.Drawing.Point(224, 20); 67 | this.button1.Name = "button1"; 68 | this.button1.Size = new System.Drawing.Size(57, 25); 69 | this.button1.TabIndex = 3; 70 | this.button1.Text = "Ok"; 71 | this.button1.UseVisualStyleBackColor = true; 72 | this.button1.Click += new System.EventHandler(this.button1_Click); 73 | // 74 | // frmCaptcha 75 | // 76 | this.AcceptButton = this.button1; 77 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 78 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 79 | this.ClientSize = new System.Drawing.Size(293, 194); 80 | this.Controls.Add(this.button1); 81 | this.Controls.Add(this.textBox1); 82 | this.Controls.Add(this.label1); 83 | this.Controls.Add(this.pictureBox1); 84 | this.MaximizeBox = false; 85 | this.MinimizeBox = false; 86 | this.Name = "frmCaptcha"; 87 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 88 | this.Text = "Please Input Captcha"; 89 | this.Load += new System.EventHandler(this.frmCaptcha_Load); 90 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 91 | this.ResumeLayout(false); 92 | this.PerformLayout(); 93 | 94 | } 95 | 96 | #endregion 97 | 98 | private System.Windows.Forms.PictureBox pictureBox1; 99 | private System.Windows.Forms.Label label1; 100 | private System.Windows.Forms.TextBox textBox1; 101 | private System.Windows.Forms.Button button1; 102 | } 103 | } -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmCaptcha.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmFileName.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace FileExplorer 2 | { 3 | partial class frmFileName 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.txName = new System.Windows.Forms.TextBox(); 33 | this.btnOk = new System.Windows.Forms.Button(); 34 | this.btnCancel = new System.Windows.Forms.Button(); 35 | this.SuspendLayout(); 36 | // 37 | // label1 38 | // 39 | this.label1.AutoSize = true; 40 | this.label1.Location = new System.Drawing.Point(29, 36); 41 | this.label1.Name = "label1"; 42 | this.label1.Size = new System.Drawing.Size(35, 12); 43 | this.label1.TabIndex = 0; 44 | this.label1.Text = "Name:"; 45 | // 46 | // txName 47 | // 48 | this.txName.ImeMode = System.Windows.Forms.ImeMode.On; 49 | this.txName.Location = new System.Drawing.Point(80, 33); 50 | this.txName.MaxLength = 50; 51 | this.txName.Name = "txName"; 52 | this.txName.Size = new System.Drawing.Size(266, 21); 53 | this.txName.TabIndex = 1; 54 | // 55 | // btnOk 56 | // 57 | this.btnOk.Location = new System.Drawing.Point(104, 74); 58 | this.btnOk.Name = "btnOk"; 59 | this.btnOk.Size = new System.Drawing.Size(75, 23); 60 | this.btnOk.TabIndex = 2; 61 | this.btnOk.Text = "Ok"; 62 | this.btnOk.UseVisualStyleBackColor = true; 63 | this.btnOk.Click += new System.EventHandler(this.btnOk_Click); 64 | // 65 | // btnCancel 66 | // 67 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 68 | this.btnCancel.Location = new System.Drawing.Point(195, 74); 69 | this.btnCancel.Name = "btnCancel"; 70 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 71 | this.btnCancel.TabIndex = 3; 72 | this.btnCancel.Text = "Cancel"; 73 | this.btnCancel.UseVisualStyleBackColor = true; 74 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 75 | // 76 | // frmFileName 77 | // 78 | this.AcceptButton = this.btnOk; 79 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 80 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 81 | this.CancelButton = this.btnCancel; 82 | this.ClientSize = new System.Drawing.Size(374, 120); 83 | this.Controls.Add(this.btnCancel); 84 | this.Controls.Add(this.btnOk); 85 | this.Controls.Add(this.txName); 86 | this.Controls.Add(this.label1); 87 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 88 | this.MaximizeBox = false; 89 | this.MinimizeBox = false; 90 | this.Name = "frmFileName"; 91 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 92 | this.Text = "Please input the name:"; 93 | this.Load += new System.EventHandler(this.frmFileName_Load); 94 | this.ResumeLayout(false); 95 | this.PerformLayout(); 96 | 97 | } 98 | 99 | #endregion 100 | 101 | private System.Windows.Forms.Label label1; 102 | private System.Windows.Forms.TextBox txName; 103 | private System.Windows.Forms.Button btnOk; 104 | private System.Windows.Forms.Button btnCancel; 105 | } 106 | } -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmFileName.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace FileExplorer 10 | { 11 | public partial class frmFileName : Form 12 | { 13 | public string FileName { get; set; } 14 | 15 | public frmFileName(string defaultName) 16 | { 17 | InitializeComponent(); 18 | txName.Text = defaultName; 19 | FileName = defaultName; 20 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 21 | txName.ImeMode = System.Windows.Forms.ImeMode.OnHalf; 22 | } 23 | 24 | private void frmFileName_Load(object sender, EventArgs e) 25 | { 26 | 27 | } 28 | 29 | private void btnOk_Click(object sender, EventArgs e) 30 | { 31 | string filename = txName.Text.Trim(); 32 | if(string.IsNullOrEmpty(filename)) 33 | { 34 | MessageBox.Show("Please input the name."); 35 | return; 36 | } 37 | FileName = filename; 38 | DialogResult = System.Windows.Forms.DialogResult.OK; 39 | Close(); 40 | } 41 | 42 | private void btnCancel_Click(object sender, EventArgs e) 43 | { 44 | Close(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmFileName.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmInput.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace FileExplorer 2 | { 3 | partial class frmInput 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.textBox1 = new System.Windows.Forms.TextBox(); 32 | this.btnOk = new System.Windows.Forms.Button(); 33 | this.btnCancel = new System.Windows.Forms.Button(); 34 | this.label1 = new System.Windows.Forms.Label(); 35 | this.SuspendLayout(); 36 | // 37 | // textBox1 38 | // 39 | this.textBox1.Location = new System.Drawing.Point(16, 59); 40 | this.textBox1.Name = "textBox1"; 41 | this.textBox1.Size = new System.Drawing.Size(256, 20); 42 | this.textBox1.TabIndex = 1; 43 | // 44 | // btnOk 45 | // 46 | this.btnOk.Location = new System.Drawing.Point(116, 95); 47 | this.btnOk.Name = "btnOk"; 48 | this.btnOk.Size = new System.Drawing.Size(75, 23); 49 | this.btnOk.TabIndex = 2; 50 | this.btnOk.Text = "Ok"; 51 | this.btnOk.UseVisualStyleBackColor = true; 52 | this.btnOk.Click += new System.EventHandler(this.btnOk_Click); 53 | // 54 | // btnCancel 55 | // 56 | this.btnCancel.Location = new System.Drawing.Point(197, 95); 57 | this.btnCancel.Name = "btnCancel"; 58 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 59 | this.btnCancel.TabIndex = 3; 60 | this.btnCancel.Text = "Cancel"; 61 | this.btnCancel.UseVisualStyleBackColor = true; 62 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 63 | // 64 | // label1 65 | // 66 | this.label1.Location = new System.Drawing.Point(13, 13); 67 | this.label1.Name = "label1"; 68 | this.label1.Size = new System.Drawing.Size(259, 43); 69 | this.label1.TabIndex = 0; 70 | this.label1.Text = "Please input"; 71 | // 72 | // frmInput 73 | // 74 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 75 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 76 | this.ClientSize = new System.Drawing.Size(284, 137); 77 | this.Controls.Add(this.btnCancel); 78 | this.Controls.Add(this.btnOk); 79 | this.Controls.Add(this.textBox1); 80 | this.Controls.Add(this.label1); 81 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 82 | this.MaximizeBox = false; 83 | this.MinimizeBox = false; 84 | this.Name = "frmInput"; 85 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 86 | this.Text = "Input form"; 87 | this.Load += new System.EventHandler(this.frmInput_Load); 88 | this.ResumeLayout(false); 89 | this.PerformLayout(); 90 | 91 | } 92 | 93 | #endregion 94 | private System.Windows.Forms.TextBox textBox1; 95 | private System.Windows.Forms.Button btnOk; 96 | private System.Windows.Forms.Button btnCancel; 97 | private System.Windows.Forms.Label label1; 98 | } 99 | } -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmInput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace FileExplorer 11 | { 12 | public partial class frmInput : Form 13 | { 14 | public string Value 15 | { 16 | get { return textBox1.Text.Trim(); } 17 | } 18 | 19 | public string Tips 20 | { 21 | get { return label1.Text; } 22 | set { label1.Text = value; } 23 | } 24 | 25 | public frmInput() 26 | { 27 | InitializeComponent(); 28 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 29 | } 30 | 31 | private void frmInput_Load(object sender, EventArgs e) 32 | { 33 | 34 | } 35 | 36 | private void btnOk_Click(object sender, EventArgs e) 37 | { 38 | DialogResult = System.Windows.Forms.DialogResult.OK; 39 | this.Close(); 40 | } 41 | 42 | private void btnCancel_Click(object sender, EventArgs e) 43 | { 44 | this.Close(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmInput.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmLogin.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | using BaiduPCS_NET; 10 | 11 | namespace FileExplorer 12 | { 13 | public partial class frmLogin : Form 14 | { 15 | BaiduPCS pcs; 16 | 17 | public frmLogin(BaiduPCS pcs) 18 | { 19 | InitializeComponent(); 20 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 21 | this.pcs = pcs; 22 | pcs.GetCaptcha += new GetCaptchaFunction(OnGetCaptcha); 23 | pcs.GetInput += new GetInputFunction(onGetInput); 24 | } 25 | 26 | private void frmLogin_Load(object sender, EventArgs e) 27 | { 28 | } 29 | 30 | protected override void OnClosing(CancelEventArgs e) 31 | { 32 | pcs.GetCaptcha -= new GetCaptchaFunction(OnGetCaptcha); 33 | pcs.GetInput -= new GetInputFunction(onGetInput); 34 | base.OnClosing(e); 35 | } 36 | 37 | private void btnOk_Click(object sender, EventArgs e) 38 | { 39 | string username = txUserName.Text.Trim(); 40 | string password = txPassword.Text.Trim(); 41 | if(string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) 42 | { 43 | MessageBox.Show("Please input User Name and Password"); 44 | return; 45 | } 46 | btnOk.Enabled = false; 47 | btnOk.Text = "Login..."; 48 | btnCancel.Enabled = false; 49 | PcsRes rc = pcs.login(username, password); 50 | if (rc != PcsRes.PCS_OK) 51 | { 52 | string errmsg = pcs.getError(); 53 | MessageBox.Show("Failed to login: " + errmsg); 54 | btnOk.Enabled = true; 55 | btnOk.Text = "Login"; 56 | btnCancel.Enabled = true; 57 | return; 58 | } 59 | DialogResult = System.Windows.Forms.DialogResult.OK; 60 | this.Close(); 61 | } 62 | 63 | private void btnCancel_Click(object sender, EventArgs e) 64 | { 65 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 66 | this.Close(); 67 | } 68 | 69 | static bool OnGetCaptcha(BaiduPCS sender, byte[] imgBytes, out string captcha, object userdata) 70 | { 71 | captcha = null; 72 | frmCaptcha frm = new frmCaptcha(imgBytes); 73 | frm.TopMost = true; 74 | if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) 75 | { 76 | captcha = frm.Captcha; 77 | return true; 78 | } 79 | return false; 80 | } 81 | 82 | private bool onGetInput(BaiduPCS sender, string tips, out string captcha, object userdata) 83 | { 84 | captcha = null; 85 | frmInput frm = new frmInput(); 86 | if (tips != null && tips.StartsWith("Please input the sms password", StringComparison.InvariantCultureIgnoreCase)) 87 | { 88 | tips = "Please input the sms password (If not receive a sms password, click cancel, and then login again)."; 89 | frm.Tips = tips; 90 | frm.Text = "Please input the sms password"; 91 | } 92 | frm.TopMost = true; 93 | if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) 94 | { 95 | captcha = frm.Value; 96 | return true; 97 | } 98 | return false; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmLogin.designer.cs: -------------------------------------------------------------------------------- 1 | namespace FileExplorer 2 | { 3 | partial class frmLogin 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.label2 = new System.Windows.Forms.Label(); 33 | this.btnOk = new System.Windows.Forms.Button(); 34 | this.btnCancel = new System.Windows.Forms.Button(); 35 | this.txUserName = new System.Windows.Forms.TextBox(); 36 | this.txPassword = new System.Windows.Forms.TextBox(); 37 | this.SuspendLayout(); 38 | // 39 | // label1 40 | // 41 | this.label1.AutoSize = true; 42 | this.label1.Location = new System.Drawing.Point(13, 34); 43 | this.label1.Name = "label1"; 44 | this.label1.Size = new System.Drawing.Size(66, 13); 45 | this.label1.TabIndex = 0; 46 | this.label1.Text = "User Name: "; 47 | // 48 | // label2 49 | // 50 | this.label2.AutoSize = true; 51 | this.label2.Location = new System.Drawing.Point(13, 71); 52 | this.label2.Name = "label2"; 53 | this.label2.Size = new System.Drawing.Size(59, 13); 54 | this.label2.TabIndex = 1; 55 | this.label2.Text = "Password: "; 56 | // 57 | // btnOk 58 | // 59 | this.btnOk.Location = new System.Drawing.Point(69, 119); 60 | this.btnOk.Name = "btnOk"; 61 | this.btnOk.Size = new System.Drawing.Size(75, 23); 62 | this.btnOk.TabIndex = 3; 63 | this.btnOk.Text = "Login"; 64 | this.btnOk.UseVisualStyleBackColor = true; 65 | this.btnOk.Click += new System.EventHandler(this.btnOk_Click); 66 | // 67 | // btnCancel 68 | // 69 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 70 | this.btnCancel.Location = new System.Drawing.Point(150, 119); 71 | this.btnCancel.Name = "btnCancel"; 72 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 73 | this.btnCancel.TabIndex = 4; 74 | this.btnCancel.Text = "Cancel"; 75 | this.btnCancel.UseVisualStyleBackColor = true; 76 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 77 | // 78 | // txUserName 79 | // 80 | this.txUserName.Location = new System.Drawing.Point(94, 31); 81 | this.txUserName.MaxLength = 50; 82 | this.txUserName.Name = "txUserName"; 83 | this.txUserName.Size = new System.Drawing.Size(159, 20); 84 | this.txUserName.TabIndex = 1; 85 | // 86 | // txPassword 87 | // 88 | this.txPassword.Location = new System.Drawing.Point(94, 68); 89 | this.txPassword.MaxLength = 50; 90 | this.txPassword.Name = "txPassword"; 91 | this.txPassword.PasswordChar = '*'; 92 | this.txPassword.Size = new System.Drawing.Size(159, 20); 93 | this.txPassword.TabIndex = 2; 94 | // 95 | // frmLogin 96 | // 97 | this.AcceptButton = this.btnOk; 98 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 99 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 100 | this.CancelButton = this.btnCancel; 101 | this.ClientSize = new System.Drawing.Size(284, 170); 102 | this.Controls.Add(this.txPassword); 103 | this.Controls.Add(this.txUserName); 104 | this.Controls.Add(this.btnCancel); 105 | this.Controls.Add(this.btnOk); 106 | this.Controls.Add(this.label2); 107 | this.Controls.Add(this.label1); 108 | this.MaximizeBox = false; 109 | this.MinimizeBox = false; 110 | this.Name = "frmLogin"; 111 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 112 | this.Text = "Login"; 113 | this.Load += new System.EventHandler(this.frmLogin_Load); 114 | this.ResumeLayout(false); 115 | this.PerformLayout(); 116 | 117 | } 118 | 119 | #endregion 120 | 121 | private System.Windows.Forms.Label label1; 122 | private System.Windows.Forms.Label label2; 123 | private System.Windows.Forms.Button btnOk; 124 | private System.Windows.Forms.Button btnCancel; 125 | private System.Windows.Forms.TextBox txUserName; 126 | private System.Windows.Forms.TextBox txPassword; 127 | } 128 | } -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmLogin.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmMain.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 479, 19 122 | 123 | 124 | 719, 17 125 | 126 | 127 | 594, 19 128 | 129 | 130 | 263, 15 131 | 132 | 133 | 874, 17 134 | 135 | 136 | 1164, 17 137 | 138 | 139 | 984, 17 140 | 141 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmMetaInformation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using System.IO; 9 | 10 | using BaiduPCS_NET; 11 | 12 | namespace FileExplorer 13 | { 14 | public partial class frmMetaInformation : Form 15 | { 16 | public frmMetaInformation(PcsFileInfo fileInfo) 17 | { 18 | InitializeComponent(); 19 | if (fileInfo.isdir) 20 | { 21 | txFileName.Text = fileInfo.server_filename; 22 | txFileType.Text = "Directory"; 23 | txLocation.Text = fileInfo.path; 24 | txSize.Text = fileInfo.size.ToString() + "Bytes (" + Utils.HumanReadableSize(fileInfo.size) + ")"; 25 | txCreateTime.Text = Utils.FromUnixTimeStamp(fileInfo.server_ctime).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); 26 | txModifyTime.Text = Utils.FromUnixTimeStamp(fileInfo.server_mtime).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); 27 | txMd5.Text = fileInfo.md5; 28 | 29 | } 30 | else 31 | { 32 | txFileName.Text = fileInfo.server_filename; 33 | txFileType.Text = Path.GetExtension(fileInfo.server_filename); 34 | txLocation.Text = fileInfo.path; 35 | txSize.Text = fileInfo.size.ToString() + "Bytes (" + Utils.HumanReadableSize(fileInfo.size) + ")"; 36 | txCreateTime.Text = Utils.FromUnixTimeStamp(fileInfo.server_ctime).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); 37 | txModifyTime.Text = Utils.FromUnixTimeStamp(fileInfo.server_mtime).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); 38 | txMd5.Text = fileInfo.md5; 39 | } 40 | } 41 | 42 | private void btnOk_Click(object sender, EventArgs e) 43 | { 44 | this.Close(); 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmMetaInformation.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmProgress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace FileExplorer 10 | { 11 | public partial class frmProgress : Form 12 | { 13 | public bool Cancelled { get; private set; } 14 | 15 | public string Label1 { get; set; } 16 | 17 | public string Label2 { get; set; } 18 | 19 | public int Value { get; set; } 20 | 21 | 22 | public frmProgress() 23 | { 24 | InitializeComponent(); 25 | } 26 | 27 | private void frmProgress_Load(object sender, EventArgs e) 28 | { 29 | Cancelled = false; 30 | timer1.Start(); 31 | } 32 | 33 | protected override void OnClosing(CancelEventArgs e) 34 | { 35 | Cancelled = true; 36 | timer1.Stop(); 37 | base.OnClosing(e); 38 | } 39 | 40 | public void CloseEx() 41 | { 42 | Cancelled = true; 43 | if (this.InvokeRequired) 44 | { 45 | this.Invoke(new VoidFun(delegate() 46 | { 47 | Close(); 48 | })); 49 | } 50 | else 51 | { 52 | Close(); 53 | } 54 | } 55 | 56 | private void timer1_Tick(object sender, EventArgs e) 57 | { 58 | if (Cancelled) 59 | return; 60 | label1.Text = Label1; 61 | label2.Text = Label2; 62 | progressBar1.Value = Value; 63 | } 64 | 65 | } 66 | public delegate void VoidFun(); 67 | } 68 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmProgress.designer.cs: -------------------------------------------------------------------------------- 1 | namespace FileExplorer 2 | { 3 | partial class frmProgress 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.progressBar1 = new System.Windows.Forms.ProgressBar(); 34 | this.label2 = new System.Windows.Forms.Label(); 35 | this.timer1 = new System.Windows.Forms.Timer(this.components); 36 | this.SuspendLayout(); 37 | // 38 | // label1 39 | // 40 | this.label1.AutoSize = true; 41 | this.label1.Location = new System.Drawing.Point(25, 21); 42 | this.label1.Name = "label1"; 43 | this.label1.Size = new System.Drawing.Size(35, 13); 44 | this.label1.TabIndex = 0; 45 | this.label1.Text = "label1"; 46 | // 47 | // progressBar1 48 | // 49 | this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 50 | | System.Windows.Forms.AnchorStyles.Right))); 51 | this.progressBar1.Location = new System.Drawing.Point(28, 46); 52 | this.progressBar1.Name = "progressBar1"; 53 | this.progressBar1.Size = new System.Drawing.Size(230, 23); 54 | this.progressBar1.Step = 1; 55 | this.progressBar1.TabIndex = 1; 56 | // 57 | // label2 58 | // 59 | this.label2.AutoSize = true; 60 | this.label2.Location = new System.Drawing.Point(34, 76); 61 | this.label2.Name = "label2"; 62 | this.label2.Size = new System.Drawing.Size(35, 13); 63 | this.label2.TabIndex = 2; 64 | this.label2.Text = "label2"; 65 | // 66 | // timer1 67 | // 68 | this.timer1.Enabled = true; 69 | this.timer1.Interval = 500; 70 | this.timer1.Tick += new System.EventHandler(this.timer1_Tick); 71 | // 72 | // frmProgress 73 | // 74 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 75 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 76 | this.ClientSize = new System.Drawing.Size(284, 98); 77 | this.Controls.Add(this.label2); 78 | this.Controls.Add(this.progressBar1); 79 | this.Controls.Add(this.label1); 80 | this.MaximizeBox = false; 81 | this.MinimizeBox = false; 82 | this.Name = "frmProgress"; 83 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 84 | this.Text = "Progress"; 85 | this.Load += new System.EventHandler(this.frmProgress_Load); 86 | this.ResumeLayout(false); 87 | this.PerformLayout(); 88 | 89 | } 90 | 91 | #endregion 92 | 93 | private System.Windows.Forms.Label label2; 94 | private System.Windows.Forms.Timer timer1; 95 | private System.Windows.Forms.Label label1; 96 | private System.Windows.Forms.ProgressBar progressBar1; 97 | 98 | } 99 | } -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmProgress.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace FileExplorer 10 | { 11 | public partial class frmSettings : Form 12 | { 13 | public frmSettings() 14 | { 15 | InitializeComponent(); 16 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 17 | numMinDownloadSliceSize.Maximum = MultiThreadDownloader.MAX_SLICE_SIZE / Utils.KB; 18 | numMinDownloadSliceSize.Minimum = MultiThreadDownloader.MIN_SLICE_SIZE / Utils.KB; 19 | } 20 | 21 | private void frmSettings_Load(object sender, EventArgs e) 22 | { 23 | ckResumeDownloadAndUploadOnStartup.Checked = AppSettings.ResumeDownloadAndUploadOnStartup; 24 | 25 | if (AppSettings.DownloadMaxThreadCount >= numDownloadMaxThreadCount.Minimum && AppSettings.DownloadMaxThreadCount <= numDownloadMaxThreadCount.Maximum) 26 | numDownloadMaxThreadCount.Value = AppSettings.DownloadMaxThreadCount; 27 | ckAutomaticDownloadMaxThreadCount.Checked = AppSettings.AutomaticDownloadMaxThreadCount; 28 | ckRetryWhenDownloadFail.Checked = AppSettings.RetryWhenDownloadFailed; 29 | if (AppSettings.MinDownloasSliceSize >= numMinDownloadSliceSize.Minimum && AppSettings.MinDownloasSliceSize <= numMinDownloadSliceSize.Maximum) 30 | numMinDownloadSliceSize.Value = AppSettings.MinDownloasSliceSize; 31 | if (AppSettings.MaxCacheSize >= numDiskCache.Minimum && AppSettings.MaxCacheSize <= numDiskCache.Maximum) 32 | numDiskCache.Value = AppSettings.MaxCacheSize; 33 | 34 | if (AppSettings.UploadMaxThreadCount >= numUploadMaxThreadCount.Minimum && AppSettings.UploadMaxThreadCount <= numUploadMaxThreadCount.Maximum) 35 | numUploadMaxThreadCount.Value = AppSettings.UploadMaxThreadCount; 36 | ckAutomaticUploadMaxThreadCount.Checked = AppSettings.AutomaticUploadMaxThreadCount; 37 | ckRetryWhenUploadFail.Checked = AppSettings.RetryWhenUploadFailed; 38 | ckOverwriteIfExists.Checked = AppSettings.OverWriteWhenUploadFile; 39 | } 40 | 41 | private void btnOk_Click(object sender, EventArgs e) 42 | { 43 | AppSettings.ResumeDownloadAndUploadOnStartup = ckResumeDownloadAndUploadOnStartup.Checked; 44 | 45 | AppSettings.DownloadMaxThreadCount = (int)numDownloadMaxThreadCount.Value; 46 | AppSettings.AutomaticDownloadMaxThreadCount = ckAutomaticDownloadMaxThreadCount.Checked; 47 | AppSettings.RetryWhenDownloadFailed = ckRetryWhenDownloadFail.Checked; 48 | AppSettings.MinDownloasSliceSize = (int)numMinDownloadSliceSize.Value; 49 | 50 | AppSettings.UploadMaxThreadCount = (int)numUploadMaxThreadCount.Value; 51 | AppSettings.AutomaticUploadMaxThreadCount = ckAutomaticUploadMaxThreadCount.Checked; 52 | AppSettings.RetryWhenUploadFailed = ckRetryWhenUploadFail.Checked; 53 | AppSettings.OverWriteWhenUploadFile = ckOverwriteIfExists.Checked; 54 | AppSettings.MaxCacheSize = (long)numDiskCache.Value; 55 | AppSettings.Save(); 56 | 57 | DialogResult = System.Windows.Forms.DialogResult.OK; 58 | this.Close(); 59 | } 60 | 61 | private void btnCancel_Click(object sender, EventArgs e) 62 | { 63 | this.Close(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmSettings.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmWaiting.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using System.Threading; 9 | 10 | namespace FileExplorer 11 | { 12 | public partial class frmWaiting : Form 13 | { 14 | public string _Title 15 | { 16 | get { return this.lblTitle.Text; } 17 | set { this.lblTitle.Text = value; } 18 | } 19 | public string _Description 20 | { 21 | get { return this.lblDescription.Text; } 22 | set { this.lblDescription.Text = value; } 23 | } 24 | 25 | public frmWaiting() 26 | : this("Wait", "Processing...") 27 | { 28 | } 29 | 30 | public frmWaiting(string title, string description) 31 | { 32 | InitializeComponent(); 33 | this.lblTitle.Text = title; 34 | this.lblDescription.Text = description; 35 | } 36 | 37 | private void frmWait_Load(object sender, EventArgs e) 38 | { 39 | 40 | } 41 | 42 | private ThreadStart threadTask = null, 43 | onDone = null; 44 | 45 | protected override void OnShown(EventArgs e) 46 | { 47 | base.OnShown(e); 48 | if (threadTask != null) 49 | { 50 | new Thread(new ThreadStart(delegate() 51 | { 52 | threadTask(); 53 | CloseSafe(); 54 | if (onDone != null) 55 | onDone(); 56 | })).Start(); 57 | } 58 | } 59 | 60 | public void Exec(ThreadStart task, ThreadStart onDone = null) 61 | { 62 | threadTask = task; 63 | this.onDone = onDone; 64 | ShowdialogSafe(); 65 | } 66 | 67 | #region Async Method 68 | 69 | public void ShowdialogSafe() 70 | { 71 | if(this.InvokeRequired) 72 | { 73 | this.Invoke(new AnonymousFunction(delegate() { 74 | ShowDialog(); 75 | })); 76 | } 77 | else 78 | { 79 | ShowDialog(); 80 | } 81 | } 82 | 83 | public void CloseSafe() 84 | { 85 | if (this.InvokeRequired) 86 | { 87 | this.Invoke(new AnonymousFunction(delegate() 88 | { 89 | Close(); 90 | })); 91 | } 92 | else 93 | { 94 | Close(); 95 | } 96 | } 97 | 98 | private delegate void SetTextFunction(string text); 99 | 100 | public void SetTitle(string title) 101 | { 102 | if (this.lblTitle.InvokeRequired) 103 | { 104 | this.lblTitle.Invoke(new SetTextFunction(SetTitle), title); 105 | } 106 | else 107 | { 108 | this.lblTitle.Text = title; 109 | } 110 | } 111 | 112 | public void SetDescription(string description) 113 | { 114 | if (this.lblDescription.InvokeRequired) 115 | { 116 | this.lblDescription.Invoke(new SetTextFunction(SetDescription), description); 117 | } 118 | else 119 | { 120 | this.lblDescription.Text = description; 121 | } 122 | } 123 | 124 | #endregion 125 | 126 | #region Drag Window 127 | private Point mouseOffset; 128 | private bool isMouseDown = false; 129 | 130 | protected virtual bool IsTileBar(int x, int y) 131 | { 132 | return x > 0 && x < 150 && y > 0 && y < 26; 133 | } 134 | 135 | protected override void OnMouseMove(MouseEventArgs e) 136 | { 137 | base.OnMouseMove(e); 138 | this.Cursor = System.Windows.Forms.Cursors.SizeAll; 139 | if (isMouseDown) 140 | { 141 | Point mousePos = Control.MousePosition; 142 | mousePos.Offset(mouseOffset.X, mouseOffset.Y); 143 | Location = mousePos; 144 | } 145 | } 146 | 147 | protected override void OnMouseUp(MouseEventArgs e) 148 | { 149 | base.OnMouseUp(e); 150 | isMouseDown = false; 151 | //if (IsTileBar(e.Location.X, e.Location.Y)) 152 | //{ 153 | // if (e.Button == MouseButtons.Left) 154 | // { 155 | // isMouseDown = false; 156 | // } 157 | //} 158 | } 159 | 160 | protected override void OnMouseDown(MouseEventArgs e) 161 | { 162 | base.OnMouseDown(e); 163 | isMouseDown = false; 164 | if (IsTileBar(e.Location.X, e.Location.Y)) 165 | { 166 | int xOffset; 167 | int yOffset; 168 | if (e.Button == MouseButtons.Left) 169 | { 170 | xOffset = -e.X - SystemInformation.FrameBorderSize.Width; 171 | yOffset = -e.Y - SystemInformation.FrameBorderSize.Height; 172 | mouseOffset = new Point(xOffset, yOffset); 173 | isMouseDown = true; 174 | } 175 | } 176 | } 177 | #endregion 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmWaiting.designer.cs: -------------------------------------------------------------------------------- 1 | namespace FileExplorer 2 | { 3 | partial class frmWaiting 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.lblTitle = new System.Windows.Forms.Label(); 32 | this.lblDescription = new System.Windows.Forms.Label(); 33 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 34 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 35 | this.SuspendLayout(); 36 | // 37 | // lblTitle 38 | // 39 | this.lblTitle.AccessibleRole = System.Windows.Forms.AccessibleRole.TitleBar; 40 | this.lblTitle.AutoSize = true; 41 | this.lblTitle.BackColor = System.Drawing.Color.Transparent; 42 | this.lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 43 | this.lblTitle.ForeColor = System.Drawing.Color.White; 44 | this.lblTitle.Location = new System.Drawing.Point(7, 6); 45 | this.lblTitle.Name = "lblTitle"; 46 | this.lblTitle.Size = new System.Drawing.Size(33, 13); 47 | this.lblTitle.TabIndex = 2; 48 | this.lblTitle.Text = "Wait"; 49 | // 50 | // lblDescription 51 | // 52 | this.lblDescription.BackColor = System.Drawing.Color.Transparent; 53 | this.lblDescription.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(58)))), ((int)(((byte)(82)))), ((int)(((byte)(177))))); 54 | this.lblDescription.Location = new System.Drawing.Point(78, 36); 55 | this.lblDescription.Name = "lblDescription"; 56 | this.lblDescription.Size = new System.Drawing.Size(171, 55); 57 | this.lblDescription.TabIndex = 3; 58 | this.lblDescription.Text = "description"; 59 | this.lblDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 60 | // 61 | // pictureBox1 62 | // 63 | this.pictureBox1.BackColor = System.Drawing.Color.Transparent; 64 | this.pictureBox1.Image = global::FileExplorer.Properties.Resources.loading; 65 | this.pictureBox1.Location = new System.Drawing.Point(9, 36); 66 | this.pictureBox1.Name = "pictureBox1"; 67 | this.pictureBox1.Size = new System.Drawing.Size(54, 55); 68 | this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; 69 | this.pictureBox1.TabIndex = 0; 70 | this.pictureBox1.TabStop = false; 71 | // 72 | // frmWaiting 73 | // 74 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 75 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 76 | this.BackgroundImage = global::FileExplorer.Properties.Resources.wait_bg; 77 | this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; 78 | this.ClientSize = new System.Drawing.Size(264, 113); 79 | this.Controls.Add(this.lblDescription); 80 | this.Controls.Add(this.pictureBox1); 81 | this.Controls.Add(this.lblTitle); 82 | this.DoubleBuffered = true; 83 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 84 | this.MaximizeBox = false; 85 | this.MinimizeBox = false; 86 | this.Name = "frmWaiting"; 87 | this.ShowIcon = false; 88 | this.ShowInTaskbar = false; 89 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 90 | this.Text = "Wait"; 91 | this.TransparencyKey = System.Drawing.SystemColors.Control; 92 | this.Load += new System.EventHandler(this.frmWait_Load); 93 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 94 | this.ResumeLayout(false); 95 | this.PerformLayout(); 96 | 97 | } 98 | 99 | #endregion 100 | 101 | private System.Windows.Forms.PictureBox pictureBox1; 102 | private System.Windows.Forms.Label lblTitle; 103 | private System.Windows.Forms.Label lblDescription; 104 | } 105 | } -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Forms/frmWaiting.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | 5 | namespace FileExplorer 6 | { 7 | static class Program 8 | { 9 | /// 10 | /// 应用程序的主入口点。 11 | /// 12 | [STAThread] 13 | static void Main() 14 | { 15 | Application.EnableVisualStyles(); 16 | Application.SetCompatibleTextRenderingDefault(false); 17 | Application.Run(new frmMain()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Explorer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Explorer")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5702020c-24f2-4c09-a92c-0a6d60bf6fbc")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.7.0")] 36 | [assembly: AssemblyFileVersion("1.0.7.0")] 37 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34209 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FileExplorer.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Worker/DUWorkerPersister.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml; 4 | using System.IO; 5 | using System.Text; 6 | 7 | namespace FileExplorer 8 | { 9 | public class DUWorkerPersister 10 | { 11 | public DUWorker worker { get; private set; } 12 | 13 | public DUWorkerPersister(DUWorker worker) 14 | { 15 | this.worker = worker; 16 | } 17 | 18 | private string GetFileName() 19 | { 20 | string filename = Path.Combine(worker.workfolder, worker.pcs.getUID(), "worker.xml"); 21 | return filename; 22 | } 23 | 24 | public bool Restore() 25 | { 26 | string filename = GetFileName(); 27 | return RestoreFrom(filename); 28 | } 29 | 30 | public bool RestoreFrom(string filename) 31 | { 32 | if (!File.Exists(filename)) 33 | return false; 34 | using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) 35 | { 36 | using(TextReader reader = new StreamReader(fs, true)) 37 | { 38 | return RestoreFrom(reader); 39 | } 40 | } 41 | } 42 | 43 | public bool RestoreFrom(TextReader reader) 44 | { 45 | XmlDocument xml = new XmlDocument(); 46 | xml.Load(reader); 47 | XmlNodeList nodes = xml.SelectNodes("/items/item"); 48 | List list = new List(nodes.Count); 49 | foreach (XmlNode n in nodes) 50 | { 51 | OperationInfo op = new OperationInfo(); 52 | XmlAttribute attr; 53 | 54 | attr = n.Attributes["uid"]; 55 | op.uid = attr != null ? attr.Value : ""; 56 | 57 | attr = n.Attributes["operation"]; 58 | op.operation = attr != null ? (Operation)Enum.Parse(typeof(Operation), attr.Value) : Operation.Download; 59 | 60 | attr = n.Attributes["from"]; 61 | op.from = attr != null ? attr.Value : ""; 62 | 63 | attr = n.Attributes["to"]; 64 | op.to = attr != null ? attr.Value : ""; 65 | 66 | attr = n.Attributes["status"]; 67 | op.status = attr != null ? (OperationStatus)Enum.Parse(typeof(OperationStatus), attr.Value) : OperationStatus.Pending; 68 | 69 | attr = n.Attributes["errmsg"]; 70 | op.errmsg = attr != null ? attr.Value : ""; 71 | 72 | attr = n.Attributes["doneSize"]; 73 | op.doneSize = attr != null ? Convert.ToInt64(attr.Value) : 0; 74 | 75 | attr = n.Attributes["totalSize"]; 76 | op.totalSize = attr != null ? Convert.ToInt64(attr.Value) : 0; 77 | 78 | attr = n.Attributes["sliceFileName"]; 79 | op.sliceFileName = attr != null ? attr.Value : ""; 80 | 81 | list.Add(op); 82 | } 83 | worker.queue.Add(list.ToArray()); 84 | return true; 85 | } 86 | 87 | public bool Save() 88 | { 89 | string filename = GetFileName(); 90 | return SaveTo(filename); 91 | } 92 | 93 | public bool SaveTo(string filename) 94 | { 95 | string dir = System.IO.Path.GetDirectoryName(filename); 96 | if (!System.IO.Directory.Exists(dir)) 97 | System.IO.Directory.CreateDirectory(dir); 98 | using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write)) 99 | { 100 | return SaveTo(fs); 101 | } 102 | } 103 | 104 | public bool SaveTo(Stream stream) 105 | { 106 | XmlWriterSettings xws = new XmlWriterSettings(); 107 | xws.Encoding = Encoding.UTF8; 108 | xws.Indent = true; 109 | using (XmlWriter writer = XmlWriter.Create(stream, xws)) 110 | { 111 | writer.WriteStartDocument(); 112 | writer.WriteStartElement("items"); 113 | 114 | foreach (OperationInfo op in worker.queue.list()) 115 | { 116 | #region 117 | 118 | writer.WriteStartElement("item"); 119 | 120 | writer.WriteStartAttribute("uid"); 121 | writer.WriteString(op.uid == null ? string.Empty : op.uid); 122 | writer.WriteEndAttribute(); 123 | 124 | writer.WriteStartAttribute("operation"); 125 | writer.WriteString(op.operation.ToString()); 126 | writer.WriteEndAttribute(); 127 | 128 | writer.WriteStartAttribute("from"); 129 | writer.WriteString(op.from == null ? string.Empty : op.from); 130 | writer.WriteEndAttribute(); 131 | 132 | writer.WriteStartAttribute("to"); 133 | writer.WriteString(op.to == null ? string.Empty : op.to); 134 | writer.WriteEndAttribute(); 135 | 136 | writer.WriteStartAttribute("status"); 137 | writer.WriteString(op.status.ToString()); 138 | writer.WriteEndAttribute(); 139 | 140 | writer.WriteStartAttribute("errmsg"); 141 | writer.WriteString(op.errmsg == null ? string.Empty : op.errmsg); 142 | writer.WriteEndAttribute(); 143 | 144 | writer.WriteStartAttribute("doneSize"); 145 | writer.WriteString(op.doneSize.ToString()); 146 | writer.WriteEndAttribute(); 147 | 148 | writer.WriteStartAttribute("totalSize"); 149 | writer.WriteString(op.totalSize.ToString()); 150 | writer.WriteEndAttribute(); 151 | 152 | writer.WriteStartAttribute("sliceFileName"); 153 | writer.WriteString(op.sliceFileName); 154 | writer.WriteEndAttribute(); 155 | 156 | writer.WriteEndElement(); 157 | 158 | #endregion 159 | } 160 | 161 | writer.WriteEndElement(); 162 | writer.WriteEndDocument(); 163 | } 164 | return true; 165 | } 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/Worker/Operation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace FileExplorer 4 | { 5 | public enum Operation 6 | { 7 | Download, 8 | Upload 9 | } 10 | 11 | public enum OperationStatus 12 | { 13 | Pending, 14 | Processing, 15 | Pause, 16 | Cancel, 17 | Success, 18 | Fail 19 | } 20 | 21 | public class OperationInfo 22 | { 23 | public string uid { get; set; } 24 | 25 | public Operation operation { get; set; } 26 | 27 | public string from { get; set; } 28 | 29 | public string to { get; set; } 30 | 31 | public OperationStatus status { get; set; } 32 | 33 | public string errmsg { get; set; } 34 | 35 | /// 36 | /// 完成量 37 | /// 38 | public long doneSize { get; set; } 39 | 40 | /// 41 | /// 总量 42 | /// 43 | public long totalSize { get; set; } 44 | 45 | /// 46 | /// 分片文件路径。内部使用。 47 | /// 48 | public string sliceFileName { get; set; } 49 | 50 | /// 51 | /// 本次服务 id。内部使用。 52 | /// 53 | public long sid { get; set; } 54 | 55 | /// 56 | /// 重试次数。内部使用。 57 | /// 58 | public int retryTimes { get; set; } 59 | 60 | /// 61 | /// 正在运行的线程数量 62 | /// 63 | public int runningThreadCount { get; set; } 64 | 65 | /// 66 | /// 总的线程数量 67 | /// 68 | public int totalThreadCount { get; set; } 69 | 70 | public object Tag { get; set; } 71 | 72 | public override bool Equals(object obj) 73 | { 74 | if (!(obj is OperationInfo)) 75 | return false; 76 | OperationInfo op = (OperationInfo)obj; 77 | if (op.operation != this.operation) 78 | return false; 79 | return string.Equals(this.from, op.from, StringComparison.InvariantCultureIgnoreCase); 80 | } 81 | 82 | public override int GetHashCode() 83 | { 84 | string s = operation.ToString() + " " + from + " to " + to; 85 | return s.GetHashCode(); 86 | } 87 | 88 | public override string ToString() 89 | { 90 | string s = "[" + status.ToString() + "] " + operation.ToString() + " " + from + " => " + to; 91 | 92 | if (status == OperationStatus.Fail) 93 | s += ": " + errmsg; 94 | else if (status == OperationStatus.Processing) 95 | s += ": " + Utils.HumanReadableSize(doneSize) + "/" + Utils.HumanReadableSize(totalSize); 96 | return s; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/history-window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/history-window.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/arrow-down-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/arrow-down-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/arrow-left-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/arrow-left-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/arrow-right-24x24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/arrow-right-24x24.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/arrow-right-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/arrow-right-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/arrow-up-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/arrow-up-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/clean-200x200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/clean-200x200.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/clean-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/clean-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/cloud-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/cloud-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/download-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/download-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/download-lightblue-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/download-lightblue-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/download-lightblue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/download-lightblue.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/folder-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/folder-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/folder.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/gear-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/gear-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/generic-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/generic-file.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/generic-folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/generic-folder.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/github.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/graphics-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/graphics-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/loading.gif -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/logout-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/logout-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/pause-200x200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/pause-200x200.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/pause-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/pause-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/play-200x200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/play-200x200.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/play-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/play-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/refresh-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/refresh-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/remove-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/remove-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/search-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/search-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/upload-2-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/upload-2-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/upload-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/upload-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/upload-orange-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/upload-orange-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/upload-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/upload-orange.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/user-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/user-32x32.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/icons/wait_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/icons/wait_bg.png -------------------------------------------------------------------------------- /Sample/Sample_0_FileExplorer/main-window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GangZhuo/BaiduPCS_NET/6c7ee3f052d7f507cf3c5c62c6d4c26669274ed4/Sample/Sample_0_FileExplorer/main-window.png --------------------------------------------------------------------------------