1.整理简化了下C#的ftp操作,方便使用

   1.支持创建多级目录

   2.批量删除

   3.整个目录上传

   4.整个目录删除

   5.整个目录下载

2.调用方法展示,

  1. var ftp = new FtpHelper("10.136.12.11", "qdx1213123", "123ddddf");//初始化ftp,创建ftp对象
  2. ftp.DelAll("test");//删除ftptest目录及其目录下的所有文件
  3. ftp.UploadAllFile("F:\\test\\wms.zip");//上传单个文件到指定目录
  4. ftp.UploadAllFile("F:\\test");//将本地test目录的所有文件上传
  5. ftp.DownloadFile("test\\wms.zip", "F:\\test1");//下载单个目录
  6. ftp.DownloadAllFile("test", "F:\\test1");//批量下载整个目录
  7. ftp.MakeDir("aaa\\bbb\\ccc\\ddd");//创建多级目录

3.FtpHelper 代码。

1.异常方法委托,通过Lamda委托统一处理异常,方便改写。加了个委托方便控制异常输出

2.ftp的删除需要递归查找所有目录存入list,然后根据 level倒序排序,从最末级开始遍历删除

3.其他的整个目录操作都是同上

  1. 1 using System;
  2. 2 using System.Collections.Generic;
  3. 3 using System.Linq;
  4. 4 using System.Net;
  5. 5 using System.IO;
  6. 6
  7. 7 namespace MyStuday
  8. 8 {
  9. 9 /// <summary>
  10. 10 /// ftp帮助类
  11. 11 /// </summary>
  12. 12 public class FtpHelper
  13. 13 {
  14. 14 private string ftpHostIP { get; set; }
  15. 15 private string username { get; set; }
  16. 16 private string password { get; set; }
  17. 17 private string ftpURI { get { return $@"ftp://{ftpHostIP}/"; } }
  18. 18
  19. 19 /// <summary>
  20. 20 /// 初始化ftp参数
  21. 21 /// </summary>
  22. 22 /// <param name="ftpHostIP">ftp主机IP</param>
  23. 23 /// <param name="username">ftp账户</param>
  24. 24 /// <param name="password">ftp密码</param>
  25. 25 public FtpHelper(string ftpHostIP, string username, string password)
  26. 26 {
  27. 27 this.ftpHostIP = ftpHostIP;
  28. 28 this.username = username;
  29. 29 this.password = password;
  30. 30 }
  31. 31
  32. 32 /// <summary>
  33. 33 /// 异常方法委托,通过Lamda委托统一处理异常,方便改写
  34. 34 /// </summary>
  35. 35 /// <param name="method">当前执行的方法</param>
  36. 36 /// <param name="action"></param>
  37. 37 /// <returns></returns>
  38. 38 private bool MethodInvoke(string method, Action action)
  39. 39 {
  40. 40 if (action != null)
  41. 41 {
  42. 42 try
  43. 43 {
  44. 44 action();
  45. 45 //Logger.Write2File($@"FtpHelper.{method}:执行成功");
  46. 46 FluentConsole.Magenta.Line($@"FtpHelper({ftpHostIP},{username},{password}).{method}:执行成功");
  47. 47 return true;
  48. 48 }
  49. 49 catch (Exception ex)
  50. 50 {
  51. 51 FluentConsole.Red.Line($@"FtpHelper({ftpHostIP},{username},{password}).{method}:执行失败:\n {ex}");
  52. 52 // Logger.Write2File(FtpHelper({ftpHostIP},{username},{password}).{method}:执行失败 \r\n{ex}");
  53. 53 return false;
  54. 54 }
  55. 55 }
  56. 56 else
  57. 57 {
  58. 58 return false;
  59. 59 }
  60. 60 }
  61. 61
  62. 62 /// <summary>
  63. 63 /// 异常方法委托,通过Lamda委托统一处理异常,方便改写
  64. 64 /// </summary>
  65. 65 /// </summary>
  66. 66 /// <typeparam name="T"></typeparam>
  67. 67 /// <param name="method"></param>
  68. 68 /// <param name="func"></param>
  69. 69 /// <returns></returns>
  70. 70 private T MethodInvoke<T>(string method, Func<T> func)
  71. 71 {
  72. 72 if (func != null)
  73. 73 {
  74. 74 try
  75. 75 {
  76. 76 //FluentConsole.Magenta.Line($@"FtpHelper({ftpHostIP},{username},{password}).{method}:执行成功");
  77. 77 //Logger.Write2File($@"FtpHelper({ftpHostIP},{username},{password}).{method}:执行成功");
  78. 78 return func();
  79. 79 }
  80. 80 catch (Exception ex)
  81. 81 {
  82. 82 //FluentConsole.Red.Line($@"FtpHelper({ftpHostIP},{username},{password}).{method}:执行失败:").Line(ex);
  83. 83 // Logger.Write2File($@"FtpHelper({ftpHostIP},{username},{password}).{method}:执行失败 \r\n{ex}");
  84. 84 return default(T);
  85. 85 }
  86. 86 }
  87. 87 else
  88. 88 {
  89. 89 return default(T);
  90. 90 }
  91. 91 }
  92. 92 private FtpWebRequest GetRequest(string URI)
  93. 93 {
  94. 94 //根据服务器信息FtpWebRequest创建类的对象
  95. 95 FtpWebRequest result = (FtpWebRequest)WebRequest.Create(URI);
  96. 96 result.Credentials = new NetworkCredential(username, password);
  97. 97 result.KeepAlive = false;
  98. 98 result.UsePassive = false;
  99. 99 result.UseBinary = true;
  100. 100 return result;
  101. 101 }
  102. 102
  103. 103 /// <summary> 上传文件</summary>
  104. 104 /// <param name="filePath">需要上传的文件路径</param>
  105. 105 /// <param name="dirName">目标路径</param>
  106. 106 public bool UploadFile(string filePath, string dirName = "")
  107. 107 {
  108. 108 FileInfo fileInfo = new FileInfo(filePath);
  109. 109 if (dirName != "") MakeDir(dirName);//检查文件目录,不存在就自动创建
  110. 110 string uri = Path.Combine(ftpURI, dirName, fileInfo.Name);
  111. 111 return MethodInvoke($@"uploadFile({filePath},{dirName})", () =>
  112. 112 {
  113. 113 FtpWebRequest ftp = GetRequest(uri);
  114. 114 ftp.Method = WebRequestMethods.Ftp.UploadFile;
  115. 115 ftp.ContentLength = fileInfo.Length;
  116. 116 int buffLength = 2048;
  117. 117 byte[] buff = new byte[buffLength];
  118. 118 int contentLen;
  119. 119 using (FileStream fs = fileInfo.OpenRead())
  120. 120 {
  121. 121 using (Stream strm = ftp.GetRequestStream())
  122. 122 {
  123. 123 contentLen = fs.Read(buff, 0, buffLength);
  124. 124 while (contentLen != 0)
  125. 125 {
  126. 126 strm.Write(buff, 0, contentLen);
  127. 127 contentLen = fs.Read(buff, 0, buffLength);
  128. 128 }
  129. 129 strm.Close();
  130. 130 }
  131. 131 fs.Close();
  132. 132 }
  133. 133 });
  134. 134 }
  135. 135
  136. 136 /// <summary>
  137. 137 /// 从一个目录将其内容复制到另一目录
  138. 138 /// </summary>
  139. 139 /// <param name="localDir">源目录</param>
  140. 140 /// <param name="DirName">目标目录</param>
  141. 141 public void UploadAllFile(string localDir, string DirName = "")
  142. 142 {
  143. 143 string localDirName = string.Empty;
  144. 144 int targIndex = localDir.LastIndexOf("\\");
  145. 145 if (targIndex > -1 && targIndex != (localDir.IndexOf(":\\") + 1))
  146. 146 localDirName = localDir.Substring(0, targIndex);
  147. 147 localDirName = localDir.Substring(targIndex + 1);
  148. 148 string newDir = Path.Combine(DirName, localDirName);
  149. 149 MethodInvoke($@"UploadAllFile({localDir},{DirName})", () =>
  150. 150 {
  151. 151 MakeDir(newDir);
  152. 152 DirectoryInfo directoryInfo = new DirectoryInfo(localDir);
  153. 153 FileInfo[] files = directoryInfo.GetFiles();
  154. 154 //复制所有文件
  155. 155 foreach (FileInfo file in files)
  156. 156 {
  157. 157 UploadFile(file.FullName, newDir);
  158. 158 }
  159. 159 //最后复制目录
  160. 160 DirectoryInfo[] directoryInfoArray = directoryInfo.GetDirectories();
  161. 161 foreach (DirectoryInfo dir in directoryInfoArray)
  162. 162 {
  163. 163 UploadAllFile(Path.Combine(localDir, dir.Name), newDir);
  164. 164 }
  165. 165 });
  166. 166 }
  167. 167
  168. 168 /// <summary>
  169. 169 /// 删除单个文件
  170. 170 /// </summary>
  171. 171 /// <param name="filePath"></param>
  172. 172 public bool DelFile(string filePath)
  173. 173 {
  174. 174 string uri = Path.Combine(ftpURI, filePath);
  175. 175 return MethodInvoke($@"DelFile({filePath})", () =>
  176. 176 {
  177. 177 FtpWebRequest ftp = GetRequest(uri);
  178. 178 ftp.Method = WebRequestMethods.Ftp.DeleteFile;
  179. 179 FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
  180. 180 response.Close();
  181. 181 });
  182. 182 }
  183. 183
  184. 184 /// <summary>
  185. 185 /// 删除最末及空目录
  186. 186 /// </summary>
  187. 187 /// <param name="dirName"></param>
  188. 188 private bool DelDir(string dirName)
  189. 189 {
  190. 190 string uri = Path.Combine(ftpURI, dirName);
  191. 191 return MethodInvoke($@"DelDir({dirName})", () =>
  192. 192 {
  193. 193 FtpWebRequest ftp = GetRequest(uri);
  194. 194 ftp.Method = WebRequestMethods.Ftp.RemoveDirectory;
  195. 195 FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
  196. 196 response.Close();
  197. 197 });
  198. 198 }
  199. 199
  200. 200 /// <summary> 删除目录或者其目录下所有的文件 </summary>
  201. 201 /// <param name="dirName">目录名称</param>
  202. 202 /// <param name="ifDelSub">是否删除目录下所有的文件</param>
  203. 203 public bool DelAll(string dirName)
  204. 204 {
  205. 205 var list = GetAllFtpFile(new List<ActFile>(),dirName);
  206. 206 if (list == null) return DelDir(dirName);
  207. 207 if (list.Count==0) return DelDir(dirName);//删除当前目录
  208. 208 var newlist = list.OrderByDescending(x => x.level);
  209. 209 foreach (var item in newlist)
  210. 210 {
  211. 211 FluentConsole.Yellow.Line($@"level:{item.level},isDir:{item.isDir},path:{item.path}");
  212. 212 }
  213. 213 string uri = Path.Combine(ftpURI, dirName);
  214. 214 return MethodInvoke($@"DelAll({dirName})", () =>
  215. 215 {
  216. 216 foreach (var item in newlist)
  217. 217 {
  218. 218 if (item.isDir)//判断是目录调用目录的删除方法
  219. 219 DelDir(item.path);
  220. 220 else
  221. 221 DelFile(item.path);
  222. 222 }
  223. 223 DelDir(dirName);//删除当前目录
  224. 224 return true;
  225. 225 });
  226. 226 }
  227. 227
  228. 228 /// <summary>
  229. 229 /// 下载单个文件
  230. 230 /// </summary>
  231. 231 /// <param name="ftpFilePath">从ftp要下载的文件路径</param>
  232. 232 /// <param name="localDir">下载至本地路径</param>
  233. 233 /// <param name="filename">文件名</param>
  234. 234 public bool DownloadFile(string ftpFilePath, string saveDir)
  235. 235 {
  236. 236 string filename = ftpFilePath.Substring(ftpFilePath.LastIndexOf("\\") + 1);
  237. 237 string tmpname = Guid.NewGuid().ToString();
  238. 238 string uri = Path.Combine(ftpURI, ftpFilePath);
  239. 239 return MethodInvoke($@"DownloadFile({ftpFilePath},{saveDir},{filename})", () =>
  240. 240 {
  241. 241 if (!Directory.Exists(saveDir)) Directory.CreateDirectory(saveDir);
  242. 242 FtpWebRequest ftp = GetRequest(uri);
  243. 243 ftp.Method = WebRequestMethods.Ftp.DownloadFile;
  244. 244 using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
  245. 245 {
  246. 246 using (Stream responseStream = response.GetResponseStream())
  247. 247 {
  248. 248 using (FileStream fs = new FileStream(Path.Combine(saveDir, filename), FileMode.CreateNew))
  249. 249 {
  250. 250 byte[] buffer = new byte[2048];
  251. 251 int read = 0;
  252. 252 do
  253. 253 {
  254. 254 read = responseStream.Read(buffer, 0, buffer.Length);
  255. 255 fs.Write(buffer, 0, read);
  256. 256 } while (!(read == 0));
  257. 257 responseStream.Close();
  258. 258 fs.Flush();
  259. 259 fs.Close();
  260. 260 }
  261. 261 responseStream.Close();
  262. 262 }
  263. 263 response.Close();
  264. 264 }
  265. 265 });
  266. 266 }
  267. 267
  268. 268 /// <summary>
  269. 269 /// 从FTP下载整个文件夹
  270. 270 /// </summary>
  271. 271 /// <param name="dirName">FTP文件夹路径</param>
  272. 272 /// <param name="saveDir">保存的本地文件夹路径</param>
  273. 273 public void DownloadAllFile(string dirName, string saveDir)
  274. 274 {
  275. 275 MethodInvoke($@"DownloadAllFile({dirName},{saveDir})", () =>
  276. 276 {
  277. 277 List<ActFile> files = GetFtpFile(dirName);
  278. 278 if (!Directory.Exists(saveDir))
  279. 279 {
  280. 280 Directory.CreateDirectory(saveDir);
  281. 281 }
  282. 282 foreach (var f in files)
  283. 283 {
  284. 284 if (f.isDir) //文件夹,递归查询
  285. 285 {
  286. 286 DownloadAllFile(Path.Combine(dirName,f.name), Path.Combine(saveDir ,f.name));
  287. 287 }
  288. 288 else //文件,直接下载
  289. 289 {
  290. 290 DownloadFile(Path.Combine(dirName,f.name), saveDir);
  291. 291 }
  292. 292 }
  293. 293 });
  294. 294 }
  295. 295
  296. 296 /// <summary>
  297. 297 /// 获取当前目录下的目录及文件
  298. 298 /// </summary>
  299. 299 /// param name="ftpfileList"></param>
  300. 300 /// <param name="dirName"></param>
  301. 301 /// <returns></returns>
  302. 302 public List<ActFile> GetFtpFile(string dirName,int ilevel = 0)
  303. 303 {
  304. 304 var ftpfileList = new List<ActFile>();
  305. 305 string uri = Path.Combine(ftpURI, dirName);
  306. 306 return MethodInvoke($@"GetFtpFile({dirName})", () =>
  307. 307 {
  308. 308 var a = new List<List<string>>();
  309. 309 FtpWebRequest ftp = GetRequest(uri);
  310. 310 ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
  311. 311 Stream stream = ftp.GetResponse().GetResponseStream();
  312. 312 using (StreamReader sr = new StreamReader(stream))
  313. 313 {
  314. 314 string line = sr.ReadLine();
  315. 315 while (!string.IsNullOrEmpty(line))
  316. 316 {
  317. 317 ftpfileList.Add(new ActFile { isDir = line.IndexOf("<DIR>") > -1, name = line.Substring(39).Trim(), path = Path.Combine(dirName, line.Substring(39).Trim()), level= ilevel });
  318. 318 line = sr.ReadLine();
  319. 319 }
  320. 320 sr.Close();
  321. 321 }
  322. 322 return ftpfileList;
  323. 323 });
  324. 324
  325. 325
  326. 326 }
  327. 327
  328. 328 /// <summary>
  329. 329 /// 获取FTP目录下的所有目录及文件包括其子目录和子文件
  330. 330 /// </summary>
  331. 331 /// param name="result"></param>
  332. 332 /// <param name="dirName"></param>
  333. 333 /// <returns></returns>
  334. 334 public List<ActFile> GetAllFtpFile(List<ActFile> result,string dirName, int level = 0)
  335. 335 {
  336. 336 var ftpfileList = new List<ActFile>();
  337. 337 string uri = Path.Combine(ftpURI, dirName);
  338. 338 return MethodInvoke($@"GetAllFtpFile({dirName})", () =>
  339. 339 {
  340. 340 ftpfileList = GetFtpFile(dirName, level);
  341. 341 result.AddRange(ftpfileList);
  342. 342 var newlist = ftpfileList.Where(x => x.isDir).ToList();
  343. 343 foreach (var item in newlist)
  344. 344 {
  345. 345 GetAllFtpFile(result,item.path, level+1);
  346. 346 }
  347. 347 return result;
  348. 348 });
  349. 349
  350. 350 }
  351. 351
  352. 352 /// <summary>
  353. 353 /// 检查目录是否存在
  354. 354 /// </summary>
  355. 355 /// <param name="dirName"></param>
  356. 356 /// <param name="currentDir"></param>
  357. 357 /// <returns></returns>
  358. 358 public bool CheckDir(string dirName, string currentDir = "")
  359. 359 {
  360. 360 string uri = Path.Combine(ftpURI, currentDir);
  361. 361 return MethodInvoke($@"CheckDir({dirName}{currentDir})", () =>
  362. 362 {
  363. 363 FtpWebRequest ftp = GetRequest(uri);
  364. 364 ftp.UseBinary = true;
  365. 365 ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
  366. 366 Stream stream = ftp.GetResponse().GetResponseStream();
  367. 367 using (StreamReader sr = new StreamReader(stream))
  368. 368 {
  369. 369 string line = sr.ReadLine();
  370. 370 while (!string.IsNullOrEmpty(line))
  371. 371 {
  372. 372 if (line.IndexOf("<DIR>") > -1)
  373. 373 {
  374. 374 if (line.Substring(39).Trim() == dirName)
  375. 375 return true;
  376. 376 }
  377. 377 line = sr.ReadLine();
  378. 378 }
  379. 379 sr.Close();
  380. 380 }
  381. 381 stream.Close();
  382. 382 return false;
  383. 383 });
  384. 384
  385. 385 }
  386. 386
  387. 387 /// </summary>
  388. 388 /// 在ftp服务器上创建指定目录,父目录不存在则创建
  389. 389 /// </summary>
  390. 390 /// <param name="dirName">创建的目录名称</param>
  391. 391 public bool MakeDir(string dirName)
  392. 392 {
  393. 393 var dirs = dirName.Split('\\').ToList();//针对多级目录分割
  394. 394 string currentDir = string.Empty;
  395. 395 return MethodInvoke($@"MakeDir({dirName})", () =>
  396. 396 {
  397. 397 foreach (var dir in dirs)
  398. 398 {
  399. 399 if (!CheckDir(dir, currentDir))//检查目录不存在则创建
  400. 400 {
  401. 401 currentDir = Path.Combine(currentDir, dir);
  402. 402 string uri = Path.Combine(ftpURI, currentDir);
  403. 403 FtpWebRequest ftp = GetRequest(uri);
  404. 404 ftp.Method = WebRequestMethods.Ftp.MakeDirectory;
  405. 405 FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
  406. 406 response.Close();
  407. 407 }
  408. 408 else
  409. 409 {
  410. 410 currentDir = Path.Combine(currentDir, dir);
  411. 411 }
  412. 412 }
  413. 413
  414. 414 });
  415. 415
  416. 416 }
  417. 417
  418. 418 /// <summary>文件重命名 </summary>
  419. 419 /// <param name="currentFilename">当前名称</param>
  420. 420 /// <param name="newFilename">重命名名称</param>
  421. 421 /// <param name="currentFilename">所在的目录</param>
  422. 422 public bool Rename(string currentFilename, string newFilename, string dirName = "")
  423. 423 {
  424. 424 string uri = Path.Combine(ftpURI, dirName, currentFilename);
  425. 425 return MethodInvoke($@"Rename({currentFilename},{newFilename},{dirName})", () =>
  426. 426 {
  427. 427 FtpWebRequest ftp = GetRequest(uri);
  428. 428 ftp.Method = WebRequestMethods.Ftp.Rename;
  429. 429 ftp.RenameTo = newFilename;
  430. 430 FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
  431. 431 response.Close();
  432. 432 });
  433. 433 }
  434. 434 }
  435. 435
  436. 436 public class ActFile
  437. 437 {
  438. 438 public int level { get; set; } = 0;
  439. 439 public bool isDir { get; set; }
  440. 440 public string name { get; set; }
  441. 441 public string path { get; set; } = "";
  442. 442 }
  443. 443 }

C#开发--FTP操作方法管理的更多相关文章

  1. C#开发-ftp操作方法整理

    1.整理简化了下C#的ftp操作,方便使用    1.支持创建多级目录    2.批量删除    3.整个目录上传    4.整个目录删除    5.整个目录下载 2.调用方法展示, var ftp ...

  2. atitit.软件开发GUI 布局管理优缺点总结java swing wpf web html c++ qt php asp.net winform

    atitit.软件开发GUI 布局管理优缺点总结java swing wpf web html c++ qt php asp.net winform 1. Absoluti 布局(经常使用) 1 2. ...

  3. IOS开发的内存管理

    关于IOS开发的内存管理的文章已经很多了,因此系统的知识点就不写了,这里我写点平时工作遇到的疑问以及解答做个总结吧,相信也会有人遇到相同的疑问呢,欢迎学习IOS的朋友请加ios技术交流群:190956 ...

  4. IOS开发小记-内存管理

    关于IOS开发的内存管理的文章已经很多了,因此系统的知识点就不写了,这里我写点平时工作遇到的疑问以及解答做个总结吧,相信也会有人遇到相同的疑问呢,欢迎学习IOS的朋友请加ios技术交流群:190956 ...

  5. 转:JAVAWEB开发之权限管理(二)——shiro入门详解以及使用方法、shiro认证与shiro授权

    原文地址:JAVAWEB开发之权限管理(二)——shiro入门详解以及使用方法.shiro认证与shiro授权 以下是部分内容,具体见原文. shiro介绍 什么是shiro shiro是Apache ...

  6. [转载]对iOS开发中内存管理的一点总结与理解

    对iOS开发中内存管理的一点总结与理解   做iOS开发也已经有两年的时间,觉得有必要沉下心去整理一些东西了,特别是一些基础的东西,虽然现在有ARC这种东西,但是我一直也没有去用过,个人觉得对内存操作 ...

  7. Atitit. 软件开发中的管理哲学--一个伟大的事业必然是过程导向为主 过程导向 vs 结果导向

    Atitit. 软件开发中的管理哲学--一个伟大的事业必然是过程导向为主    过程导向 vs 结果导向 1. 一个伟大的事业必然是过程导向为主 1 1.1. 过程的执行情况(有明确的执行手册及标准) ...

  8. vue组件化开发-vuex状态管理库

    Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化.Vuex 也集成到 Vue 的官方调试工具 ...

  9. Java语言实现简单FTP软件------>辅助功能模块FTP站点管理的实现(十二)

    1.FTP站点管理 点击"FTP站点管理"按钮,弹出对话框"FTP站点管理",如下图 1) 连接站点 在FTP站点管理面板上选好要连接的站点,点击"连 ...

随机推荐

  1. zabbix 硬盘状态收集,制作表格

    将zabbix首页复制到a文件里,这里主要是用到首页里 最近出现的问题 的信息 # -*- coding:utf-8 -*- import time import os from openpyxl i ...

  2. javaweb核心技术servlet

      一.Servlet简介 1.什么是Servlet Servlet 运行在服务端的Java小程序,是sun公司提供一套规范(接口),用来处理客户端请求.响应给浏览器的动态资源.但servlet的实质 ...

  3. bzoj2301(莫比乌斯反演)

    bzoj2301 题意 求区间 [a, b] 和 区间 [c, d] 有多少对数 (x, y) 使得 gcd(x, y) = k . 分析 参考ppt 参考blog 考虑用容斥分成四次查询, 对于每次 ...

  4. 洛谷——P1143 进制转换

    P1143 进制转换 题目描述 请你编一程序实现两种不同进制之间的数据转换. 输入输出格式 输入格式: 输入数据共有三行,第一行是一个正整数,表示需要转换的数的进制n(2≤n≤16),第二行是一个n进 ...

  5. Java多线程中的异常处理

    在java多线程程序中,所有线程都不允许抛出未捕获的checked exception,也就是说各个线程需要自己把自己的checked exception处理掉.这一点是通过java.lang.Run ...

  6. UVA 103 Stacking Boxes n维最长上升子序列

    题目链接:UVA - 103 题意:现有k个箱子,每个箱子可以用n维向量表示.如果一个箱子的n维向量均比另一个箱子的n维向量大,那么它们可以套接在一起,每个箱子的n维向量可以互相交换值,如箱子(2,6 ...

  7. Android之9图的制作

    .9.PNG确实是标准的PNG格式,只是在最外面一圈额外增加1px的边框,这个1px的边框就是用来定义图片中可扩展的和静态不变的区域.特别说明,left和top边框中交叉部分是可拉伸部分,未选中部分是 ...

  8. C/C++框架和库 (真的很强大) 转

    http://blog.csdn.net/xiaoxiaoyeyaya/article/details/42541419     值得学习的C语言开源项目 - 1. Webbench Webbench ...

  9. pr_debug、dev_dbg等动态调试三

    内核版本:Linux-3.14 作者:彭东林 邮箱:pengdonglin137@163.com 如果没有使用CONFIG_DYNAMIC_DEBUG,那么就需要定义DEBUG,那么此时pr_debu ...

  10. [置顶] kubernetes资源类型--持久化存储Persistent Volume和Persistent Volume Claim

    概念 存储管理跟计算管理是两个不同的问题.理解每个存储系统是一件复杂的事情,特别是对于普通用户来说,有时并不需要关心各种存储实现,只希望能够安全可靠地存储数据. 为了简化对存储调度,K8S对存储的供应 ...