DirectoryTest.cs 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  1. //
  2. // System.IO.Directory
  3. //
  4. // Authors:
  5. // Ville Palo ([email protected])
  6. //
  7. // (C) 2003 Ville Palo
  8. //
  9. // TODO: Find out why ArgumentOutOfRange tests does not release directories properly
  10. //
  11. using NUnit.Framework;
  12. using System.IO;
  13. using System.Text;
  14. using System;
  15. using System.Globalization;
  16. using System.Threading;
  17. namespace MonoTests.System.IO {
  18. [TestFixture]
  19. public class DirectoryTest : Assertion {
  20. string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");
  21. static readonly char DSC = Path.DirectorySeparatorChar;
  22. [SetUp]
  23. public void SetUp ()
  24. {
  25. if (!Directory.Exists (TempFolder))
  26. Directory.CreateDirectory (TempFolder);
  27. Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
  28. }
  29. [TearDown]
  30. public void TearDown () {
  31. if (Directory.Exists (TempFolder))
  32. Directory.Delete (TempFolder, true);
  33. }
  34. [Test]
  35. public void CreateDirectory ()
  36. {
  37. string path = TempFolder + DSC + "DirectoryTest.Test.1";
  38. DeleteDirectory (path);
  39. try {
  40. DirectoryInfo info = Directory.CreateDirectory (path);
  41. AssertEquals ("test#01", true, info.Exists);
  42. AssertEquals ("test#02", ".1", info.Extension);
  43. AssertEquals ("test#03", true, info.FullName.EndsWith ("DirectoryTest.Test.1"));
  44. AssertEquals ("test#04", "DirectoryTest.Test.1", info.Name);
  45. } finally {
  46. DeleteDirectory (path);
  47. }
  48. }
  49. [Test]
  50. [ExpectedException(typeof(ArgumentException))]
  51. public void CreateDirectoryNotSupportedException ()
  52. {
  53. DeleteDirectory (":");
  54. DirectoryInfo info = Directory.CreateDirectory (":");
  55. DeleteDirectory (":");
  56. }
  57. [Test]
  58. [ExpectedException(typeof(ArgumentNullException))]
  59. public void CreateDirectoryArgumentNullException ()
  60. {
  61. DirectoryInfo info = Directory.CreateDirectory (null as string);
  62. }
  63. [Test]
  64. [ExpectedException(typeof(ArgumentException))]
  65. public void CreateDirectoryArgumentException1 ()
  66. {
  67. DirectoryInfo info = Directory.CreateDirectory ("");
  68. }
  69. [Test]
  70. [ExpectedException(typeof(ArgumentException))]
  71. public void CreateDirectoryArgumentException2 ()
  72. {
  73. DirectoryInfo info = Directory.CreateDirectory (" ");
  74. }
  75. [Test]
  76. [ExpectedException(typeof(ArgumentException))]
  77. public void CreateDirectoryArgumentException3 ()
  78. {
  79. string path = TempFolder + DSC + "DirectoryTest.Test";
  80. DeleteDirectory (path);
  81. try {
  82. path += Path.InvalidPathChars [0];
  83. path += ".2";
  84. DirectoryInfo info = Directory.CreateDirectory (path);
  85. } finally {
  86. DeleteDirectory (path);
  87. }
  88. }
  89. [Test]
  90. public void Delete ()
  91. {
  92. string path = TempFolder + DSC + "DirectoryTest.Test.Delete.1";
  93. DeleteDirectory (path);
  94. try {
  95. Directory.CreateDirectory (path);
  96. AssertEquals ("test#01", true, Directory.Exists (path));
  97. Directory.CreateDirectory (path + DSC + "DirectoryTest.Test.Delete.1.2");
  98. AssertEquals ("test#02", true, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));
  99. Directory.Delete (path + DSC + "DirectoryTest.Test.Delete.1.2");
  100. AssertEquals ("test#03", false, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));
  101. AssertEquals ("test#04", true, Directory.Exists (path));
  102. Directory.Delete (path);
  103. AssertEquals ("test#05", false, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));
  104. AssertEquals ("test#06", false, Directory.Exists (path));
  105. Directory.CreateDirectory (path);
  106. Directory.CreateDirectory (path + DSC + "DirectoryTest.Test.Delete.1.2");
  107. AssertEquals ("test#07", true, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));
  108. AssertEquals ("test#08", true, Directory.Exists (path));
  109. Directory.Delete (path, true);
  110. AssertEquals ("test#09", false, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));
  111. AssertEquals ("test#10", false, Directory.Exists (path));
  112. } finally {
  113. DeleteDirectory (path);
  114. }
  115. }
  116. [Test]
  117. [ExpectedException(typeof(ArgumentException))]
  118. public void DeleteArgumentException ()
  119. {
  120. Directory.Delete ("");
  121. }
  122. [Test]
  123. [ExpectedException(typeof(ArgumentException))]
  124. public void DeleteArgumentException2 ()
  125. {
  126. Directory.Delete (" ");
  127. }
  128. [Test]
  129. [ExpectedException(typeof(ArgumentException))]
  130. public void DeleteArgumentException3 ()
  131. {
  132. string path = TempFolder + DSC + "DirectoryTest.Test.4";
  133. DeleteDirectory (path);
  134. path += Path.InvalidPathChars [0];
  135. Directory.Delete (path);
  136. }
  137. [Test]
  138. [ExpectedException(typeof(ArgumentNullException))]
  139. public void DeleteArgumentNullException ()
  140. {
  141. Directory.Delete (null as string);
  142. }
  143. [Test]
  144. [ExpectedException(typeof(DirectoryNotFoundException))]
  145. public void DeleteDirectoryNotFoundException ()
  146. {
  147. string path = TempFolder + DSC + "DirectoryTest.Test.5";
  148. DeleteDirectory (path);
  149. Directory.Delete (path);
  150. }
  151. [Test]
  152. [ExpectedException(typeof(IOException))]
  153. public void DeleteArgumentException4 ()
  154. {
  155. string path = TempFolder + DSC + "DirectoryTest.Test.6";
  156. DeleteDirectory (path);
  157. FileStream s = null;
  158. Directory.CreateDirectory (path);
  159. try {
  160. s = File.Create (path + DSC + "DirectoryTest.Test.6");
  161. Directory.Delete (path);
  162. } finally {
  163. if (s != null)
  164. s.Close ();
  165. DeleteDirectory (path);
  166. };
  167. }
  168. [Test]
  169. public void Exists ()
  170. {
  171. AssertEquals ("test#01", false, Directory.Exists (null as string));
  172. }
  173. [Test]
  174. [ExpectedException(typeof(ArgumentNullException))]
  175. public void GetCreationTimeException1 ()
  176. {
  177. Directory.GetCreationTime (null as string);
  178. }
  179. [Test]
  180. [ExpectedException(typeof(ArgumentException))]
  181. public void GetCreationTimeException2 ()
  182. {
  183. Directory.GetCreationTime ("");
  184. }
  185. [Test]
  186. #if !NET_2_0
  187. [ExpectedException(typeof(IOException))]
  188. #endif
  189. public void GetCreationTimeException_NonExistingPath ()
  190. {
  191. string path = TempFolder + DSC + "DirectoryTest.GetCreationTime.1";
  192. DeleteDirectory (path);
  193. try {
  194. DateTime time = Directory.GetCreationTime (path);
  195. #if NET_2_0
  196. DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
  197. Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
  198. Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
  199. Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
  200. Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
  201. Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
  202. Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
  203. #endif
  204. } finally {
  205. DeleteDirectory (path);
  206. }
  207. }
  208. [Test]
  209. [ExpectedException(typeof(ArgumentException))]
  210. public void GetCreationTimeException4 ()
  211. {
  212. Directory.GetCreationTime (" ");
  213. }
  214. [Test]
  215. [ExpectedException(typeof(ArgumentException))]
  216. public void GetCreationTimeException5 ()
  217. {
  218. Directory.GetCreationTime (Path.InvalidPathChars [0].ToString ());
  219. }
  220. [Test]
  221. [ExpectedException(typeof(ArgumentNullException))]
  222. public void GetCreationTimeUtcException1 ()
  223. {
  224. Directory.GetCreationTimeUtc (null as string);
  225. }
  226. [Test]
  227. [ExpectedException(typeof(ArgumentException))]
  228. public void GetCreationTimeUtcException2 ()
  229. {
  230. Directory.GetCreationTimeUtc ("");
  231. }
  232. [Test]
  233. #if !NET_2_0
  234. [ExpectedException (typeof (IOException))]
  235. #endif
  236. public void GetCreationTimeUtc_NonExistingPath ()
  237. {
  238. string path = TempFolder + DSC + "DirectoryTest.GetCreationTimeUtc.1";
  239. DeleteDirectory (path);
  240. try {
  241. DateTime time = Directory.GetCreationTimeUtc (path);
  242. #if NET_2_0
  243. Assertion.AssertEquals ("#1", 1601, time.Year);
  244. Assertion.AssertEquals ("#2", 1, time.Month);
  245. Assertion.AssertEquals ("#3", 1, time.Day);
  246. Assertion.AssertEquals ("#4", 0, time.Hour);
  247. Assertion.AssertEquals ("#5", 0, time.Second);
  248. Assertion.AssertEquals ("#6", 0, time.Millisecond);
  249. #endif
  250. } finally {
  251. DeleteDirectory (path);
  252. }
  253. }
  254. [Test]
  255. [ExpectedException(typeof(ArgumentException))]
  256. public void GetCreationTimeUtcException4 ()
  257. {
  258. Directory.GetCreationTimeUtc (" ");
  259. }
  260. [Test]
  261. [ExpectedException(typeof(ArgumentException))]
  262. public void GetCreationTimeUtcException5 ()
  263. {
  264. Directory.GetCreationTime (Path.InvalidPathChars [0].ToString ());
  265. }
  266. [Test]
  267. [ExpectedException(typeof(ArgumentNullException))]
  268. public void GetLastAccessTimeException1 ()
  269. {
  270. Directory.GetLastAccessTime (null as string);
  271. }
  272. [Test]
  273. [ExpectedException(typeof(ArgumentException))]
  274. public void GetLastAccessTimeException2 ()
  275. {
  276. Directory.GetLastAccessTime ("");
  277. }
  278. [Test]
  279. #if !NET_2_0
  280. [ExpectedException (typeof (IOException))]
  281. #endif
  282. public void GetLastAccessTime_NonExistingPath ()
  283. {
  284. string path = TempFolder + DSC + "DirectoryTest.GetLastAccessTime.1";
  285. DeleteDirectory (path);
  286. try {
  287. DateTime time = Directory.GetLastAccessTime (path);
  288. #if NET_2_0
  289. DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
  290. Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
  291. Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
  292. Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
  293. Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
  294. Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
  295. Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
  296. #endif
  297. } finally {
  298. DeleteDirectory (path);
  299. }
  300. }
  301. [Test]
  302. [ExpectedException(typeof(ArgumentException))]
  303. public void GetLastAccessTimeException4 ()
  304. {
  305. Directory.GetLastAccessTime (" ");
  306. }
  307. [Test]
  308. [ExpectedException(typeof(ArgumentException))]
  309. public void GetLastAccessTimeException5 ()
  310. {
  311. Directory.GetLastAccessTime (Path.InvalidPathChars [0].ToString ());
  312. }
  313. [Test]
  314. [ExpectedException(typeof(ArgumentNullException))]
  315. public void GetLastAccessTimeUtcException1 ()
  316. {
  317. Directory.GetLastAccessTimeUtc (null as string);
  318. }
  319. [Test]
  320. [ExpectedException(typeof(ArgumentException))]
  321. public void GetLastAccessTimeUtcException2 ()
  322. {
  323. Directory.GetLastAccessTimeUtc ("");
  324. }
  325. [Test]
  326. #if !NET_2_0
  327. [ExpectedException (typeof (IOException))]
  328. #endif
  329. public void GetLastAccessTimeUtc_NonExistingPath ()
  330. {
  331. string path = TempFolder + DSC + "DirectoryTest.GetLastAccessTimeUtc.1";
  332. DeleteDirectory (path);
  333. try {
  334. DateTime time = Directory.GetLastAccessTimeUtc (path);
  335. #if NET_2_0
  336. Assertion.AssertEquals ("#1", 1601, time.Year);
  337. Assertion.AssertEquals ("#2", 1, time.Month);
  338. Assertion.AssertEquals ("#3", 1, time.Day);
  339. Assertion.AssertEquals ("#4", 0, time.Hour);
  340. Assertion.AssertEquals ("#5", 0, time.Second);
  341. Assertion.AssertEquals ("#6", 0, time.Millisecond);
  342. #endif
  343. } finally {
  344. DeleteDirectory (path);
  345. }
  346. }
  347. [Test]
  348. [ExpectedException(typeof(ArgumentException))]
  349. public void GetLastAccessTimeUtcException4 ()
  350. {
  351. Directory.GetLastAccessTimeUtc (" ");
  352. }
  353. [Test]
  354. [ExpectedException(typeof(ArgumentException))]
  355. public void GetLastAccessTimeUtcException5 ()
  356. {
  357. Directory.GetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString ());
  358. }
  359. [Test]
  360. [ExpectedException(typeof(ArgumentNullException))]
  361. public void GetLastWriteTimeException1 ()
  362. {
  363. Directory.GetLastWriteTime (null as string);
  364. }
  365. [Test]
  366. [ExpectedException(typeof(ArgumentException))]
  367. public void GetLastWriteTimeException2 ()
  368. {
  369. Directory.GetLastWriteTime ("");
  370. }
  371. [Test]
  372. #if !NET_2_0
  373. [ExpectedException (typeof (IOException))]
  374. #endif
  375. public void GetLastWriteTime_NonExistingPath ()
  376. {
  377. string path = TempFolder + DSC + "DirectoryTest.GetLastWriteTime.1";
  378. DeleteDirectory (path);
  379. try {
  380. DateTime time = Directory.GetLastWriteTime (path);
  381. #if NET_2_0
  382. DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();
  383. Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);
  384. Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);
  385. Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);
  386. Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);
  387. Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);
  388. Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);
  389. #endif
  390. } finally {
  391. DeleteDirectory (path);
  392. }
  393. }
  394. [Test]
  395. [ExpectedException(typeof(ArgumentException))]
  396. public void GetLastWriteTimeException4 ()
  397. {
  398. Directory.GetLastWriteTime (" ");
  399. }
  400. [Test]
  401. [ExpectedException(typeof(ArgumentException))]
  402. public void GetLastWriteTimeException5 ()
  403. {
  404. Directory.GetLastWriteTime (Path.InvalidPathChars [0].ToString ());
  405. }
  406. [Test]
  407. [ExpectedException(typeof(ArgumentNullException))]
  408. public void GetLastWriteTimeUtcException1 ()
  409. {
  410. Directory.GetLastWriteTimeUtc (null as string);
  411. }
  412. [Test]
  413. [ExpectedException(typeof(ArgumentException))]
  414. public void GetLastWriteTimeUtcException2 ()
  415. {
  416. Directory.GetLastWriteTimeUtc ("");
  417. }
  418. [Test]
  419. #if !NET_2_0
  420. [ExpectedException (typeof (IOException))]
  421. #endif
  422. public void GetLastWriteTimeUtc_NonExistingPath ()
  423. {
  424. string path = TempFolder + DSC + "DirectoryTest.GetLastWriteTimeUtc.1";
  425. DeleteDirectory (path);
  426. try {
  427. DateTime time = Directory.GetLastWriteTimeUtc (path);
  428. #if NET_2_0
  429. Assertion.AssertEquals ("#1", 1601, time.Year);
  430. Assertion.AssertEquals ("#2", 1, time.Month);
  431. Assertion.AssertEquals ("#3", 1, time.Day);
  432. Assertion.AssertEquals ("#4", 0, time.Hour);
  433. Assertion.AssertEquals ("#5", 0, time.Second);
  434. Assertion.AssertEquals ("#6", 0, time.Millisecond);
  435. #endif
  436. } finally {
  437. DeleteDirectory (path);
  438. }
  439. }
  440. [Test]
  441. [ExpectedException(typeof(ArgumentException))]
  442. public void GetLastWriteTimeUtcException4 ()
  443. {
  444. Directory.GetLastWriteTimeUtc (" ");
  445. }
  446. [Test]
  447. [ExpectedException(typeof(ArgumentException))]
  448. public void GetLastWriteTimeUtcException5 ()
  449. {
  450. Directory.GetLastWriteTimeUtc (Path.InvalidPathChars[0].ToString ());
  451. }
  452. [Test]
  453. public void Move ()
  454. {
  455. string path = TempFolder + DSC + "DirectoryTest.Test.9";
  456. string path2 = TempFolder + DSC + "DirectoryTest.Test.10";
  457. DeleteDirectory (path);
  458. DeleteDirectory (path2);
  459. try {
  460. Directory.CreateDirectory (path);
  461. Directory.CreateDirectory (path + DSC + "dir");
  462. AssertEquals ("test#01", true, Directory.Exists (path + DSC + "dir"));
  463. Directory.Move (path, path2);
  464. AssertEquals ("test#02", false, Directory.Exists (path + DSC + "dir"));
  465. AssertEquals ("test#03", true, Directory.Exists (path2 + DSC + "dir"));
  466. } finally {
  467. DeleteDirectory (path);
  468. DeleteDirectory (path2);
  469. if (Directory.Exists (path2 + DSC + "dir"))
  470. Directory.Delete (path2 + DSC + "dir", true);
  471. }
  472. }
  473. [Test]
  474. [ExpectedException(typeof(IOException))]
  475. public void MoveException1 ()
  476. {
  477. string path = TempFolder + DSC + "DirectoryTest.Test.8";
  478. DeleteDirectory (path);
  479. try {
  480. Directory.Move (path, path);
  481. } finally {
  482. DeleteDirectory (path);
  483. }
  484. }
  485. [Test]
  486. [ExpectedException(typeof(ArgumentException))]
  487. public void MoveException2 ()
  488. {
  489. string path = TempFolder + DSC + "DirectoryTest.Test.11";
  490. DeleteDirectory (path);
  491. try {
  492. Directory.Move ("", path);
  493. } finally {
  494. DeleteDirectory (path);
  495. }
  496. }
  497. [Test]
  498. [ExpectedException(typeof(ArgumentException))]
  499. public void MoveException3 ()
  500. {
  501. string path = TempFolder + DSC + "DirectoryTest.Test.12";
  502. DeleteDirectory (path);
  503. try {
  504. Directory.Move (" ", path);
  505. } finally {
  506. DeleteDirectory (path);
  507. }
  508. }
  509. [Test]
  510. [ExpectedException(typeof(ArgumentException))]
  511. public void MoveException4 ()
  512. {
  513. string path = TempFolder + DSC + "DirectoryTest.Test.13";
  514. path += Path.InvalidPathChars [0];
  515. string path2 = TempFolder + DSC + "DirectoryTest.Test.13";
  516. DeleteDirectory (path);
  517. DeleteDirectory (path2);
  518. try {
  519. Directory.CreateDirectory (path2);
  520. Directory.Move (path2, path);
  521. } finally {
  522. DeleteDirectory (path);
  523. DeleteDirectory (path2);
  524. }
  525. }
  526. [Test]
  527. [ExpectedException(typeof(DirectoryNotFoundException))]
  528. public void MoveException5 ()
  529. {
  530. string path = TempFolder + DSC + "DirectoryTest.Test.14";
  531. DeleteDirectory (path);
  532. try {
  533. Directory.Move (path, path + "Test.Test");
  534. } finally {
  535. DeleteDirectory (path);
  536. DeleteDirectory (path + "Test.Test");
  537. }
  538. }
  539. [Test]
  540. [ExpectedException(typeof(IOException))]
  541. public void MoveException6 ()
  542. {
  543. string path = TempFolder + DSC + "DirectoryTest.Test.15";
  544. DeleteDirectory (path);
  545. try {
  546. Directory.CreateDirectory (path);
  547. Directory.Move (path, path + DSC + "dir");
  548. } finally {
  549. DeleteDirectory (path);
  550. DeleteDirectory (path + DSC + "dir");
  551. }
  552. }
  553. [Test]
  554. [ExpectedException(typeof(IOException))]
  555. public void MoveException7 ()
  556. {
  557. string path = TempFolder + DSC + "DirectoryTest.Test.16";
  558. string path2 = TempFolder + DSC + "DirectoryTest.Test.17";
  559. DeleteDirectory (path);
  560. DeleteDirectory (path2);
  561. try {
  562. Directory.CreateDirectory (path);
  563. Directory.CreateDirectory (path2);
  564. Directory.Move (path, path2);
  565. } finally {
  566. DeleteDirectory (path);
  567. DeleteDirectory (path2);
  568. }
  569. }
  570. [Test]
  571. [Ignore("Unix doesnt support CreationTime")]
  572. public void CreationTime ()
  573. {
  574. string path = TempFolder + DSC + "DirectoryTest.CreationTime.1";
  575. DeleteDirectory (path);
  576. try {
  577. Directory.CreateDirectory (path);
  578. Directory.SetCreationTime (path, new DateTime (2003, 6, 4, 6, 4, 0));
  579. DateTime time = Directory.GetCreationTime (path);
  580. AssertEquals ("test#01", 2003, time.Year);
  581. AssertEquals ("test#02", 6, time.Month);
  582. AssertEquals ("test#03", 4, time.Day);
  583. AssertEquals ("test#04", 6, time.Hour);
  584. AssertEquals ("test#05", 4, time.Minute);
  585. AssertEquals ("test#06", 0, time.Second);
  586. time = TimeZone.CurrentTimeZone.ToLocalTime (Directory.GetCreationTimeUtc (path));
  587. AssertEquals ("test#07", 2003, time.Year);
  588. AssertEquals ("test#08", 6, time.Month);
  589. AssertEquals ("test#09", 4, time.Day);
  590. AssertEquals ("test#10", 6, time.Hour);
  591. AssertEquals ("test#11", 4, time.Minute);
  592. AssertEquals ("test#12", 0, time.Second);
  593. Directory.SetCreationTimeUtc (path, new DateTime (2003, 6, 4, 6, 4, 0));
  594. time = TimeZone.CurrentTimeZone.ToUniversalTime (Directory.GetCreationTime (path));
  595. AssertEquals ("test#13", 2003, time.Year);
  596. AssertEquals ("test#14", 6, time.Month);
  597. AssertEquals ("test#15", 4, time.Day);
  598. AssertEquals ("test#16", 6, time.Hour);
  599. AssertEquals ("test#17", 4, time.Minute);
  600. AssertEquals ("test#18", 0, time.Second);
  601. time = Directory.GetCreationTimeUtc (path);
  602. AssertEquals ("test#19", 2003, time.Year);
  603. AssertEquals ("test#20", 6, time.Month);
  604. AssertEquals ("test#21", 4, time.Day);
  605. AssertEquals ("test#22", 6, time.Hour);
  606. AssertEquals ("test#23", 4, time.Minute);
  607. AssertEquals ("test#24", 0, time.Second);
  608. } finally {
  609. DeleteDirectory (path);
  610. }
  611. }
  612. [Test]
  613. public void LastAccessTime ()
  614. {
  615. string path = TempFolder + DSC + "DirectoryTest.AccessTime.1";
  616. DeleteDirectory (path);
  617. try {
  618. Directory.CreateDirectory (path);
  619. Directory.SetLastAccessTime (path, new DateTime (2003, 6, 4, 6, 4, 0));
  620. DateTime time = Directory.GetLastAccessTime (path);
  621. AssertEquals ("test#01", 2003, time.Year);
  622. AssertEquals ("test#02", 6, time.Month);
  623. AssertEquals ("test#03", 4, time.Day);
  624. AssertEquals ("test#04", 6, time.Hour);
  625. AssertEquals ("test#05", 4, time.Minute);
  626. AssertEquals ("test#06", 0, time.Second);
  627. time = TimeZone.CurrentTimeZone.ToLocalTime (Directory.GetLastAccessTimeUtc (path));
  628. AssertEquals ("test#07", 2003, time.Year);
  629. AssertEquals ("test#08", 6, time.Month);
  630. AssertEquals ("test#09", 4, time.Day);
  631. AssertEquals ("test#10", 6, time.Hour);
  632. AssertEquals ("test#11", 4, time.Minute);
  633. AssertEquals ("test#12", 0, time.Second);
  634. Directory.SetLastAccessTimeUtc (path, new DateTime (2003, 6, 4, 6, 4, 0));
  635. time = TimeZone.CurrentTimeZone.ToUniversalTime (Directory.GetLastAccessTime (path));
  636. AssertEquals ("test#13", 2003, time.Year);
  637. AssertEquals ("test#14", 6, time.Month);
  638. AssertEquals ("test#15", 4, time.Day);
  639. AssertEquals ("test#16", 6, time.Hour);
  640. AssertEquals ("test#17", 4, time.Minute);
  641. AssertEquals ("test#18", 0, time.Second);
  642. time = Directory.GetLastAccessTimeUtc (path);
  643. AssertEquals ("test#19", 2003, time.Year);
  644. AssertEquals ("test#20", 6, time.Month);
  645. AssertEquals ("test#21", 4, time.Day);
  646. AssertEquals ("test#22", 6, time.Hour);
  647. AssertEquals ("test#23", 4, time.Minute);
  648. AssertEquals ("test#24", 0, time.Second);
  649. } finally {
  650. DeleteDirectory (path);
  651. }
  652. }
  653. [Test]
  654. public void LastWriteTime ()
  655. {
  656. string path = TempFolder + DSC + "DirectoryTest.WriteTime.1";
  657. DeleteDirectory (path);
  658. try {
  659. Directory.CreateDirectory (path);
  660. Directory.SetLastWriteTime (path, new DateTime (2003, 6, 4, 6, 4, 0));
  661. DateTime time = Directory.GetLastWriteTime (path);
  662. AssertEquals ("test#01", 2003, time.Year);
  663. AssertEquals ("test#02", 6, time.Month);
  664. AssertEquals ("test#03", 4, time.Day);
  665. AssertEquals ("test#04", 6, time.Hour);
  666. AssertEquals ("test#05", 4, time.Minute);
  667. AssertEquals ("test#06", 0, time.Second);
  668. time = TimeZone.CurrentTimeZone.ToLocalTime (Directory.GetLastWriteTimeUtc (path));
  669. AssertEquals ("test#07", 2003, time.Year);
  670. AssertEquals ("test#08", 6, time.Month);
  671. AssertEquals ("test#09", 4, time.Day);
  672. AssertEquals ("test#10", 6, time.Hour);
  673. AssertEquals ("test#11", 4, time.Minute);
  674. AssertEquals ("test#12", 0, time.Second);
  675. Directory.SetLastWriteTimeUtc (path, new DateTime (2003, 6, 4, 6, 4, 0));
  676. time = TimeZone.CurrentTimeZone.ToUniversalTime (Directory.GetLastWriteTime (path));
  677. AssertEquals ("test#13", 2003, time.Year);
  678. AssertEquals ("test#14", 6, time.Month);
  679. AssertEquals ("test#15", 4, time.Day);
  680. AssertEquals ("test#16", 6, time.Hour);
  681. AssertEquals ("test#17", 4, time.Minute);
  682. AssertEquals ("test#18", 0, time.Second);
  683. time = Directory.GetLastWriteTimeUtc (path);
  684. AssertEquals ("test#19", 2003, time.Year);
  685. AssertEquals ("test#20", 6, time.Month);
  686. AssertEquals ("test#21", 4, time.Day);
  687. AssertEquals ("test#22", 6, time.Hour);
  688. AssertEquals ("test#23", 4, time.Minute);
  689. AssertEquals ("test#24", 0, time.Second);
  690. } finally {
  691. DeleteDirectory (path);
  692. }
  693. }
  694. [Test]
  695. [ExpectedException(typeof(ArgumentNullException))]
  696. public void SetLastWriteTimeException1 ()
  697. {
  698. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  699. Directory.SetLastWriteTime (null as string, time);
  700. }
  701. [Test]
  702. [ExpectedException(typeof(ArgumentException))]
  703. public void SetLastWriteTimeException2 ()
  704. {
  705. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  706. Directory.SetLastWriteTime ("", time);
  707. }
  708. [Test]
  709. [ExpectedException(typeof(FileNotFoundException))]
  710. public void SetLastWriteTimeException3 ()
  711. {
  712. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  713. string path = TempFolder + DSC + "DirectoryTest.SetLastWriteTime.2";
  714. DeleteDirectory (path);
  715. try {
  716. Directory.SetLastWriteTime (path, time);
  717. } finally {
  718. DeleteDirectory (path);
  719. }
  720. }
  721. [Test]
  722. [ExpectedException(typeof(ArgumentException))]
  723. public void SetLastWriteTimeException4 ()
  724. {
  725. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  726. Directory.SetLastWriteTime (" ", time);
  727. }
  728. [Test]
  729. [ExpectedException(typeof(ArgumentException))]
  730. public void SetLastWriteTimeException5 ()
  731. {
  732. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  733. Directory.SetLastWriteTime (Path.InvalidPathChars [0].ToString (), time);
  734. }
  735. // [Test]
  736. // [ExpectedException(typeof(ArgumentOutOfRangeException))]
  737. // public void SetLastWriteTimeException6 ()
  738. // {
  739. // DateTime time = new DateTime (1003, 4, 6, 6, 4, 2);
  740. // string path = TempFolder + Path.DirectorySeparatorChar + "DirectoryTest.SetLastWriteTime.1";
  741. //
  742. // try {
  743. // if (!Directory.Exists (path))
  744. // Directory.CreateDirectory (path);
  745. //
  746. // Directory.SetLastWriteTime (path, time);
  747. // } finally {
  748. // DeleteDirectory (path);
  749. // }
  750. //
  751. // }
  752. [Test]
  753. [ExpectedException(typeof(ArgumentNullException))]
  754. public void SetLastWriteTimeUtcException1 ()
  755. {
  756. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  757. Directory.SetLastWriteTimeUtc (null as string, time);
  758. }
  759. [Test]
  760. [ExpectedException(typeof(ArgumentException))]
  761. public void SetLastWriteTimeUtcException2 ()
  762. {
  763. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  764. Directory.SetLastWriteTimeUtc ("", time);
  765. }
  766. [Test]
  767. [ExpectedException(typeof(FileNotFoundException))]
  768. public void SetLastWriteTimeUtcException3 ()
  769. {
  770. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  771. string path = TempFolder + DSC + "DirectoryTest.SetLastWriteTimeUtc.2";
  772. DeleteDirectory (path);
  773. try {
  774. Directory.SetLastWriteTimeUtc (path, time);
  775. } finally {
  776. DeleteDirectory (path);
  777. }
  778. }
  779. [Test]
  780. [ExpectedException(typeof(ArgumentException))]
  781. public void SetLastWriteTimeUtcException4 ()
  782. {
  783. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  784. Directory.SetLastWriteTimeUtc (" ", time);
  785. }
  786. [Test]
  787. [ExpectedException(typeof(ArgumentException))]
  788. public void SetLastWriteTimeUtcException5 ()
  789. {
  790. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  791. Directory.SetLastWriteTimeUtc (Path.InvalidPathChars [0].ToString (), time);
  792. }
  793. // [Test]
  794. // [ExpectedException(typeof(ArgumentOutOfRangeException))]
  795. // public void SetLastWriteTimeUtcException6 ()
  796. // {
  797. // DateTime time = new DateTime (1000, 4, 6, 6, 4, 2);
  798. // string path = TempFolder + DSC + "DirectoryTest.SetLastWriteTimeUtc.1";
  799. //
  800. // if (!Directory.Exists (path))
  801. // Directory.CreateDirectory (path);
  802. // try {
  803. // Directory.SetLastWriteTimeUtc (path, time);
  804. // } finally {
  805. // DeleteDirectory (path);
  806. // }
  807. // }
  808. [Test]
  809. [ExpectedException(typeof(ArgumentNullException))]
  810. public void SetLastAccessTimeException1 ()
  811. {
  812. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  813. Directory.SetLastAccessTime (null as string, time);
  814. }
  815. [Test]
  816. [ExpectedException(typeof(ArgumentException))]
  817. public void SetLastAccessTimeException2 ()
  818. {
  819. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  820. Directory.SetLastAccessTime ("", time);
  821. }
  822. [Test]
  823. [ExpectedException(typeof(FileNotFoundException))]
  824. public void SetLastAccessTimeException3 ()
  825. {
  826. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  827. string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTime.2";
  828. DeleteDirectory (path);
  829. try {
  830. Directory.SetLastAccessTime (path, time);
  831. } finally {
  832. DeleteDirectory (path);
  833. }
  834. }
  835. [Test]
  836. [ExpectedException(typeof(ArgumentException))]
  837. public void SetLastAccessTimeException4 ()
  838. {
  839. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  840. Directory.SetLastAccessTime (" ", time);
  841. }
  842. [Test]
  843. [ExpectedException(typeof(ArgumentException))]
  844. public void SetLastAccessTimeException5 ()
  845. {
  846. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  847. Directory.SetLastAccessTime (Path.InvalidPathChars [0].ToString (), time);
  848. }
  849. // [Test]
  850. // [ExpectedException(typeof(ArgumentOutOfRangeException))]
  851. // public void SetLastAccessTimeException6 ()
  852. // {
  853. // DateTime time = new DateTime (1003, 4, 6, 6, 4, 2);
  854. // string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTime.1";
  855. //
  856. // if (!Directory.Exists (path))
  857. // Directory.CreateDirectory (path);
  858. // try {
  859. // Directory.SetLastAccessTime (path, time);
  860. // } finally {
  861. // DeleteDirectory (path);
  862. // }
  863. //
  864. // }
  865. [Test]
  866. [ExpectedException(typeof(ArgumentNullException))]
  867. public void SetLastAccessTimeUtcException1 ()
  868. {
  869. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  870. Directory.SetLastAccessTimeUtc (null as string, time);
  871. }
  872. [Test]
  873. [ExpectedException(typeof(ArgumentException))]
  874. public void SetLastAccessTimeUtcException2 ()
  875. {
  876. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  877. Directory.SetLastAccessTimeUtc ("", time);
  878. }
  879. [Test]
  880. [ExpectedException(typeof(FileNotFoundException))]
  881. public void SetLastAccessTimeUtcException3 ()
  882. {
  883. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  884. string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.2";
  885. DeleteDirectory (path);
  886. try {
  887. Directory.SetLastAccessTimeUtc (path, time);
  888. } finally {
  889. DeleteDirectory (path);
  890. }
  891. }
  892. [Test]
  893. [ExpectedException(typeof(ArgumentException))]
  894. public void SetLastAccessTimeUtcException4 ()
  895. {
  896. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  897. Directory.SetLastAccessTimeUtc (" ", time);
  898. }
  899. [Test]
  900. [ExpectedException(typeof(ArgumentException))]
  901. public void SetLastAccessTimeUtcException5 ()
  902. {
  903. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  904. Directory.SetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString (), time);
  905. }
  906. // [Test]
  907. // [ExpectedException(typeof(ArgumentOutOfRangeException))]
  908. // public void SetLastAccessTimeUtcException6 ()
  909. // {
  910. // DateTime time = new DateTime (1000, 4, 6, 6, 4, 2);
  911. // string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.1";
  912. //
  913. // if (!Directory.Exists (path))
  914. // Directory.CreateDirectory (path);
  915. // try {
  916. // Directory.SetLastAccessTimeUtc (path, time);
  917. // } finally {
  918. // DeleteDirectory (path);
  919. // }
  920. // }
  921. [Test]
  922. [ExpectedException(typeof(ArgumentNullException))]
  923. public void SetCreationTimeException1 ()
  924. {
  925. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  926. Directory.SetCreationTime (null as string, time);
  927. }
  928. [Test]
  929. [ExpectedException(typeof(ArgumentException))]
  930. public void SetCreationTimeException2 ()
  931. {
  932. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  933. Directory.SetCreationTime ("", time);
  934. }
  935. [Test]
  936. [ExpectedException(typeof(FileNotFoundException))]
  937. public void SetCreationTimeException3 ()
  938. {
  939. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  940. string path = TempFolder + DSC + "DirectoryTest.SetCreationTime.2";
  941. DeleteDirectory (path);
  942. try {
  943. Directory.SetCreationTime (path, time);
  944. } finally {
  945. DeleteDirectory (path);
  946. }
  947. }
  948. [Test]
  949. [ExpectedException(typeof(ArgumentException))]
  950. public void SetCreationTimeException4 ()
  951. {
  952. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  953. Directory.SetCreationTime (" ", time);
  954. }
  955. [Test]
  956. [ExpectedException(typeof(ArgumentException))]
  957. public void SetCreationTimeException5 ()
  958. {
  959. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  960. Directory.SetCreationTime (Path.InvalidPathChars [0].ToString (), time);
  961. }
  962. // [Test]
  963. // [ExpectedException(typeof(ArgumentOutOfRangeException))]
  964. // public void SetCreationTimeException6 ()
  965. // {
  966. // DateTime time = new DateTime (1003, 4, 6, 6, 4, 2);
  967. // string path = TempFolder + DSC + "DirectoryTest.SetCreationTime.1";
  968. //
  969. // if (!Directory.Exists (path))
  970. // Directory.CreateDirectory (path);
  971. // try {
  972. // Directory.SetCreationTime (path, time);
  973. // DeleteDirectory (path);
  974. // } finally {
  975. // DeleteDirectory (path);
  976. // }
  977. //
  978. // }
  979. [Test]
  980. [ExpectedException(typeof(ArgumentNullException))]
  981. public void SetCreationTimeUtcException1 ()
  982. {
  983. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  984. Directory.SetCreationTimeUtc (null as string, time);
  985. }
  986. [Test]
  987. [ExpectedException(typeof(ArgumentException))]
  988. public void SetCreationTimeUtcException2 ()
  989. {
  990. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  991. Directory.SetCreationTimeUtc ("", time);
  992. }
  993. [Test]
  994. [ExpectedException(typeof(FileNotFoundException))]
  995. public void SetCreationTimeUtcException3 ()
  996. {
  997. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  998. string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.2";
  999. DeleteDirectory (path);
  1000. try {
  1001. Directory.SetCreationTimeUtc (path, time);
  1002. DeleteDirectory (path);
  1003. } finally {
  1004. DeleteDirectory (path);
  1005. }
  1006. }
  1007. [Test]
  1008. [ExpectedException(typeof(ArgumentException))]
  1009. public void SetCreationTimeUtcException4 ()
  1010. {
  1011. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  1012. Directory.SetCreationTimeUtc (" ", time);
  1013. }
  1014. [Test]
  1015. [ExpectedException(typeof(ArgumentException))]
  1016. public void SetCreationTimeUtcException5 ()
  1017. {
  1018. DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);
  1019. Directory.SetCreationTimeUtc (Path.InvalidPathChars [0].ToString (), time);
  1020. }
  1021. // [Test]
  1022. // [ExpectedException(typeof(ArgumentOutOfRangeException))]
  1023. // public void SetCreationTimeUtcException6 ()
  1024. // {
  1025. // DateTime time = new DateTime (1000, 4, 6, 6, 4, 2);
  1026. // string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.1";
  1027. //
  1028. // if (!Directory.Exists (path))
  1029. // Directory.CreateDirectory (path);
  1030. // try {
  1031. // Directory.SetCreationTimeUtc (path, time);
  1032. // DeleteDirectory (path);
  1033. // } finally {
  1034. // DeleteDirectory (path);
  1035. // }
  1036. // }
  1037. [Test]
  1038. public void GetDirectories ()
  1039. {
  1040. string path = TempFolder;
  1041. string DirPath = TempFolder + Path.DirectorySeparatorChar + ".GetDirectories";
  1042. DeleteDirectory (DirPath);
  1043. try {
  1044. Directory.CreateDirectory (DirPath);
  1045. string [] dirs = Directory.GetDirectories (path);
  1046. foreach (string directory in dirs) {
  1047. if (directory == DirPath)
  1048. return;
  1049. }
  1050. Assert ("Directory Not Found", false);
  1051. } finally {
  1052. DeleteDirectory (DirPath);
  1053. }
  1054. }
  1055. [Test]
  1056. public void GetParentOfRootDirectory ()
  1057. {
  1058. DirectoryInfo info;
  1059. info = Directory.GetParent (Path.GetPathRoot (Path.GetTempPath ()));
  1060. AssertEquals (null, info);
  1061. }
  1062. [Test]
  1063. public void GetFiles ()
  1064. {
  1065. string path = TempFolder;
  1066. string DirPath = TempFolder + Path.DirectorySeparatorChar + ".GetFiles";
  1067. if (File.Exists (DirPath))
  1068. File.Delete (DirPath);
  1069. try {
  1070. File.Create (DirPath).Close ();
  1071. string [] files = Directory.GetFiles (TempFolder);
  1072. foreach (string directory in files) {
  1073. if (directory == DirPath)
  1074. return;
  1075. }
  1076. Assert ("File Not Found", false);
  1077. } finally {
  1078. if (File.Exists (DirPath))
  1079. File.Delete (DirPath);
  1080. }
  1081. }
  1082. [Test]
  1083. [ExpectedException (typeof (ArgumentNullException))]
  1084. public void SetCurrentDirectoryNull ()
  1085. {
  1086. Directory.SetCurrentDirectory (null);
  1087. }
  1088. [Test]
  1089. [ExpectedException (typeof (ArgumentException))]
  1090. public void SetCurrentDirectoryEmpty ()
  1091. {
  1092. Directory.SetCurrentDirectory (String.Empty);
  1093. }
  1094. [Test]
  1095. [ExpectedException (typeof (ArgumentException))]
  1096. public void SetCurrentDirectoryWhitespace ()
  1097. {
  1098. Directory.SetCurrentDirectory (" ");
  1099. }
  1100. [Test]
  1101. public void GetNoFiles () // Bug 58875. This throwed an exception on windows.
  1102. {
  1103. DirectoryInfo dir = new DirectoryInfo (".");
  1104. dir.GetFiles ("*.nonext");
  1105. }
  1106. private void DeleteDirectory (string path)
  1107. {
  1108. if (Directory.Exists (path))
  1109. Directory.Delete (path, true);
  1110. }
  1111. }
  1112. }