BindingFlags.Public needed here as Exception.HResult is now public in .NET 4.5. This...
[mono.git] / mcs / class / corlib / Test / System.IO.IsolatedStorage / IsolatedStorageFileTest.cs
1 //
2 // IsolatedStorageFileTest.cs 
3 //      - Unit Tests for abstract IsolatedStorageFile class
4 //
5 // Author:
6 //      Sebastien Pouliot  <sebastien@ximian.com>
7 //
8 // Copyright (C) 2005 Novell Inc. (http://www.novell.com)
9 // Copyright 2011 Xamarin Inc (http://www.xamarin.com).
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System;
32 using System.Collections;
33 using System.IO;
34 using System.IO.IsolatedStorage;
35 using System.Reflection;
36 using System.Security;
37 using System.Security.Permissions;
38 using System.Security.Policy;
39
40 using NUnit.Framework;
41
42 namespace MonoTests.System.IO.IsolatedStorageTest {
43
44         [TestFixture]
45         public class IsolatedStorageFileTest {
46
47                 private const string dirname = "mono-unit-test";
48
49                 private void CheckEnumerated (int n, IsolatedStorageScope scope, IsolatedStorageFile isf)
50                 {
51                         string prefix = n.ToString () + " - " + scope.ToString () + " - ";
52                         Assert.IsNotNull (isf, prefix + "IsolatedStorageFile");
53                         Assert.IsTrue (((scope & isf.Scope) != 0), prefix + "Scope");
54
55                         if ((isf.Scope & IsolatedStorageScope.Assembly) != 0)
56                                 Assert.IsNotNull (isf.AssemblyIdentity, prefix + "AssemblyIdentity");
57                         if ((isf.Scope & IsolatedStorageScope.Domain) != 0)
58                                 Assert.IsNotNull (isf.DomainIdentity, prefix + "DomainIdentity");
59 #if NET_2_0
60                         if ((isf.Scope & IsolatedStorageScope.Application) != 0)
61                                 Assert.IsNotNull (isf.ApplicationIdentity, prefix + "ApplicationIdentity");
62 #endif
63                 }
64
65                 private void GetEnumerator (IsolatedStorageScope scope)
66                 {
67                         IEnumerator e = IsolatedStorageFile.GetEnumerator (scope);
68                         int n = 0;
69                         while (e.MoveNext ())
70                         {
71                                 IsolatedStorageFile isf = (IsolatedStorageFile)e.Current;
72                                 CheckEnumerated (++n, scope, isf);
73                         }
74                 }
75
76                 [Test]
77                 public void GetEnumerator_User ()
78                 {
79                         GetEnumerator (IsolatedStorageScope.User);
80                 }
81
82                 [Test]
83                 [ExpectedException (typeof (ArgumentException))]
84                 public void GetEnumerator_User_Details ()
85                 {
86                         // giving more details is bad
87                         GetEnumerator (IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain);
88                 }
89
90                 [Test]
91                 public void GetEnumerator_UserRoaming ()
92                 {
93                         GetEnumerator (IsolatedStorageScope.User | IsolatedStorageScope.Roaming);
94                 }
95
96                 [Test]
97                 [ExpectedException (typeof (ArgumentException))]
98                 public void GetEnumerator_UserRoaming_Details ()
99                 {
100                         // giving more details is bad
101                         GetEnumerator (IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain | IsolatedStorageScope.Roaming);
102                 }
103 #if NET_2_0
104                 [Test]
105                 public void GetEnumerator_Machine ()
106                 {
107                         GetEnumerator (IsolatedStorageScope.Machine);
108                 }
109
110                 [Test]
111                 [ExpectedException (typeof (ArgumentException))]
112                 public void GetEnumerator_Machine_Details ()
113                 {
114                         GetEnumerator (IsolatedStorageScope.Machine | IsolatedStorageScope.Assembly);
115                 }
116
117                 [Test]
118                 [ExpectedException (typeof (ArgumentException))]
119                 public void GetEnumerator_Application ()
120                 {
121                         // we can't enum application
122                         GetEnumerator (IsolatedStorageScope.Application);
123                 }
124 #endif
125                 [Test]
126                 public void GetUserStoreForAssembly ()
127                 {
128                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
129                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
130                         Assert.AreEqual (IsolatedStorageScope.User | IsolatedStorageScope.Assembly, isf.Scope, "Scope");
131 #if !NET_2_1
132                         Assert.IsTrue ((isf.AssemblyIdentity is Url), "AssemblyIdentity");
133                         // note: mono transforms the CodeBase into uppercase
134                         // for net 1.1 which uses file:// and not file:///
135                         string codebase = Assembly.GetExecutingAssembly ().CodeBase.ToUpper ().Substring (8);
136                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().ToUpper ().IndexOf (codebase) > 0), "Url");
137                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().ToUpper ().IndexOf (codebase) > 0), "Url");
138 #endif
139                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
140                 }
141
142                 [Test]
143                 [ExpectedException (typeof (InvalidOperationException))]
144                 public void GetUserStoreForAssembly_DomainIdentity ()
145                 {
146                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
147                         object o = isf.DomainIdentity;
148                 }
149
150 #if NET_2_0
151                 [Test]
152                 [ExpectedException (typeof (InvalidOperationException))]
153                 public void GetUserStoreForAssembly_ApplicationIdentity ()
154                 {
155                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
156                         object o = isf.ApplicationIdentity;
157                 }
158 #endif
159
160                 [Test]
161                 public void GetUserStoreForDomain ()
162                 {
163                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForDomain ();
164                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
165                         Assert.AreEqual (IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, isf.Scope, "Scope");
166 #if !NET_2_1
167                         Assert.IsTrue ((isf.AssemblyIdentity is Url), "AssemblyIdentity");
168                         // note: mono transforms the CodeBase into uppercase
169                         // for net 1.1 which uses file:// and not file:///
170                         string codebase = Assembly.GetExecutingAssembly ().CodeBase.ToUpper ().Substring (8);
171                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().ToUpper ().IndexOf (codebase) > 0), "Url");
172                         Assert.IsTrue ((isf.DomainIdentity is Url), "DomainIdentity");
173                         // note: with MS Assembly.GetEntryAssembly () only works in the default (first) AppDomain
174                         // so we're using the first parameter to GetCommandLineArgs
175                         string exe = Environment.GetCommandLineArgs ()[0].Replace ("\\", "/").ToUpper ();
176                         Assert.IsTrue ((isf.DomainIdentity.ToString ().ToUpper ().IndexOf (exe) > 0), exe + "\n" + isf.DomainIdentity.ToString ().ToUpper ()); //"Url - Domain");
177 #endif
178                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
179                 }
180
181 #if NET_2_0
182                 [Test]
183                 [ExpectedException (typeof (InvalidOperationException))]
184                 public void GetUserStoreForDomain_ApplicationIdentity ()
185                 {
186                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForDomain ();
187                         object o = isf.ApplicationIdentity;
188                 }
189
190                 [Test]
191                 [ExpectedException (typeof (IsolatedStorageException))]
192                 public void GetUserStoreForApplication_WithoutApplicationIdentity ()
193                 {
194                         // note: a manifest is required
195                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
196                 }
197
198                 [Test]
199                 [ExpectedException (typeof (IsolatedStorageException))]
200                 public void GetUserStoreForApplication ()
201                 {
202                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
203                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
204 #if !NET_2_1
205                         Assert.AreEqual (IsolatedStorageScope.User | IsolatedStorageScope.Assembly, isf.Scope, "Scope");
206                         Assert.IsTrue ((isf.AssemblyIdentity is Url), "AssemblyIdentity");
207                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf (Assembly.GetExecutingAssembly ().CodeBase) > 0), "Url");
208 #endif
209                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
210                 }
211                 
212 #if !NET_2_1
213                 [Test]
214                 [ExpectedException (typeof (IsolatedStorageException))]
215                 public void GetUserStoreForApplication_AssemblyIdentity ()
216                 {
217                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
218                         object o = isf.AssemblyIdentity;
219                 }
220
221                 [Test]
222                 [ExpectedException (typeof (IsolatedStorageException))]
223                 public void GetUserStoreForApplication_DomainIdentity ()
224                 {
225                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication ();
226                         object o = isf.DomainIdentity;
227                 }
228 #endif
229 #endif
230
231 #if NET_4_0
232                 // This is supposed to be working only in SL.
233                 [Test]
234                 [ExpectedException (typeof (NotSupportedException))]
235                 public void GetUserStoreForSite ()
236                 {
237                         IsolatedStorageFile.GetUserStoreForSite ();
238                 }
239 #endif
240
241                 [Test]
242                 public void GetStore_Domain_Zone ()
243                 {
244                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
245                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, typeof (Zone), typeof (Zone));
246                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
247 #if !NET_2_1
248                         Assert.AreEqual (IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, isf.Scope, "Scope");
249                         Assert.IsTrue ((isf.AssemblyIdentity is Zone), "AssemblyIdentity");
250                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf ("MyComputer") > 0), "Zone - Assembly");
251                         Assert.IsTrue ((isf.DomainIdentity is Zone), "DomainIdentity");
252                         Assert.IsTrue ((isf.DomainIdentity.ToString ().IndexOf ("MyComputer") > 0), "Zone - Domain");
253 #endif
254                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
255                 }
256
257                 [Test]
258                 [ExpectedException (typeof (IsolatedStorageException))]
259                 public void GetStore_Domain_NonPresentEvidences ()
260                 {
261                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
262                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, typeof (StrongName), typeof (Publisher));
263                 }
264
265                 [Test]
266                 public void GetStore_Assembly_NonPresentDomainEvidences ()
267                 {
268                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
269                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, typeof (StrongName), typeof (Url));
270                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
271                         Assert.AreEqual (scope, isf.Scope, "Scope");
272 #if !NET_2_1
273                         Assert.IsTrue ((isf.AssemblyIdentity is Url), "AssemblyIdentity");
274                         // note: mono transforms the CodeBase into uppercase
275                         // for net 1.1 which uses file:// and not file:///
276                         string codebase = Assembly.GetExecutingAssembly ().CodeBase.ToUpper ().Substring (8);
277                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().ToUpper ().IndexOf (codebase) > 0), "Url");
278                         // DomainIdentity throws a InvalidOperationException
279 #endif
280                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
281                 }
282
283                 [Test]
284                 [ExpectedException (typeof (ArgumentNullException))]
285                 public void GetStore_Domain_DomainNullObject ()
286                 {
287                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
288                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (object)null, new Zone (SecurityZone.MyComputer));
289                 }
290
291                 [Test]
292                 [ExpectedException (typeof (ArgumentNullException))]
293                 public void GetStore_Domain_AssemblyNullObject ()
294                 {
295                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
296                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, new Zone (SecurityZone.MyComputer), (object)null);
297                 }
298
299                 [Test]
300                 public void GetStore_Assembly_DomainNullObject ()
301                 {
302                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
303                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (object)null, new Zone (SecurityZone.Internet));
304                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
305                         Assert.AreEqual (scope, isf.Scope, "Scope");
306                         Assert.IsTrue ((isf.AssemblyIdentity is Zone), "AssemblyIdentity");
307                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf ("Internet") > 0), "Zone - Assembly");
308                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
309                 }
310
311                 [Test]
312                 [ExpectedException (typeof (ArgumentNullException))]
313                 public void GetStore_Assembly_AssemblyNullObject ()
314                 {
315                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
316                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, new Zone (SecurityZone.MyComputer), (object)null);
317                 }
318
319                 [Test]
320                 public void GetStore_Domain_ZoneObjectZoneObject ()
321                 {
322                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
323                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, new Zone (SecurityZone.Internet), new Zone (SecurityZone.Internet));
324                         Assert.AreEqual (Int64.MaxValue, isf.MaximumSize, "MaximumSize");
325                         Assert.AreEqual (scope, isf.Scope, "Scope");
326                         Assert.IsTrue ((isf.AssemblyIdentity is Zone), "AssemblyIdentity");
327                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf ("Internet") > 0), "Zone - Assembly");
328                         Assert.IsTrue ((isf.DomainIdentity is Zone), "DomainIdentity");
329                         Assert.IsTrue ((isf.DomainIdentity.ToString ().IndexOf ("Internet") > 0), "Zone - Domain");
330                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
331                 }
332 #if NET_2_0
333                 [Test]
334                 [ExpectedException (typeof (ArgumentNullException))]
335                 public void GetStore_Application_NullObject ()
336                 {
337                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Application;
338                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (object)null);
339                 }
340
341                 [Test]
342                 [ExpectedException (typeof (IsolatedStorageException))]
343                 public void GetStore_Application_NullType ()
344                 {
345                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Application;
346                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, (Type)null);
347                         // again it's the lack of a manifest
348                 }
349 #endif
350
351                 [Test]
352                 public void GetStore_DomainScope_Evidences ()
353                 {
354                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
355
356                         Evidence de = new Evidence ();
357                         de.AddHost (new Zone (SecurityZone.Internet));
358                         Evidence ae = new Evidence ();
359                         ae.AddHost (new Zone (SecurityZone.Intranet));
360                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, de, typeof (Zone), ae, typeof (Zone));
361
362                         // Maximum size for Internet isn't (by default) Int64.MaxValue
363                         Assert.AreEqual (scope, isf.Scope, "Scope");
364 #if !NET_2_1
365                         Assert.IsTrue ((isf.AssemblyIdentity is Zone), "AssemblyIdentity");
366                         Assert.IsTrue ((isf.AssemblyIdentity.ToString ().IndexOf ("Intranet") > 0), "Zone - Assembly");
367                         Assert.IsTrue ((isf.DomainIdentity is Zone), "DomainIdentity");
368                         Assert.IsTrue ((isf.DomainIdentity.ToString ().IndexOf ("Internet") > 0), isf.DomainIdentity.ToString ()); //"Zone - Domain");
369 #endif
370                         Assert.IsTrue ((isf.CurrentSize >= 0), "CurrentSize");
371                 }
372
373                 [Test]
374                 [ExpectedException (typeof (ArgumentNullException))]
375                 public void GetStore_DomainScope_Evidence_NullAssemblyEvidence ()
376                 {
377                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
378
379                         Evidence de = new Evidence ();
380                         de.AddHost (new Zone (SecurityZone.Internet));
381                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, de, typeof (Zone), null, null);
382                 }
383
384                 [Test]
385                 [ExpectedException (typeof (ArgumentNullException))]
386                 public void GetStore_DomainScope_Evidence_NullDomainEvidence ()
387                 {
388                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly;
389
390                         Evidence ae = new Evidence ();
391                         ae.AddHost (new Zone (SecurityZone.Internet));
392                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, null, null, ae, typeof (Zone));
393                 }
394
395                 [Test]
396                 [ExpectedException (typeof (ArgumentNullException))]
397                 public void GetStore_AssemblyScope_Evidence_NullAssemblyEvidence ()
398                 {
399                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
400
401                         Evidence de = new Evidence ();
402                         de.AddHost (new Zone (SecurityZone.Internet));
403                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, de, typeof (Zone), null, null);
404                 }
405
406                 [Test]
407                 public void GetStore_AssemblyScope_Evidence_NullDomainEvidence ()
408                 {
409                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Assembly;
410
411                         Evidence ae = new Evidence ();
412                         ae.AddHost (new Zone (SecurityZone.Internet));
413                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, null, null, ae, typeof (Zone));
414                 }
415
416                 [Test]
417                 public void RegressionBNC354539 ()
418                 {
419                         string filename = "test-bnc-354539";
420                         byte[] expected = new byte[] { 0x01, 0x42, 0x00 };
421                         byte[] actual = new byte [expected.Length];
422
423                         using (IsolatedStorageFile file = IsolatedStorageFile.GetStore (IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null)) {
424                                 using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream (filename, FileMode.Create, FileAccess.Write, FileShare.None, file)) {
425                                         stream.Write (expected, 0, expected.Length);
426                                 }
427                         }
428
429                         using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForAssembly ()) {
430                                 using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read, file)) {
431                                         stream.Read (actual, 0, actual.Length);
432                                 }
433
434                                 file.DeleteFile (filename);
435                         }
436                         
437                         Assert.AreEqual (expected, actual);
438                 }
439
440                 [Test]
441                 [ExpectedException (typeof (ArgumentNullException))]
442                 public void CreateDirectory_Null ()
443                 {
444                         IsolatedStorageFile.GetUserStoreForAssembly ().CreateDirectory (null);
445                 }
446
447                 [Test]
448                 public void CreateDirectory_FileWithSameNameExists ()
449                 {
450                         string path = "bug374377";
451                         using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForDomain ()) {
452                                 using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream (path, FileMode.OpenOrCreate, isf)) {
453                                 }
454                                 try {
455                                         isf.CreateDirectory (path);
456                                 }
457 #if NET_4_0 || NET_2_1
458                                 catch (IsolatedStorageException ex) {
459                                         Assert.IsFalse (ex.Message.IndexOf (path) >= 0, "Message");
460                                         Assert.IsNull (ex.InnerException, "InnerException");
461                                 }
462 #else
463                                 catch (IOException ex) {
464                                         Assert.AreEqual (typeof (IOException), ex.GetType (), "Type");
465                                         // don't leak path information
466                                         Assert.IsFalse (ex.Message.IndexOf (path) >= 0, "Message");
467                                         Assert.IsNull (ex.InnerException, "InnerException");
468                                 }
469 #endif
470                         }
471                 }
472
473                 [Test]
474                 public void CreateDirectory_DirectoryWithSameNameExists ()
475                 {
476                         string dir = "new-dir";
477                         string file = Path.Combine (dir, "new-file");
478                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
479                         try {
480                                 isf.CreateDirectory (dir);
481                                 using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream (file, FileMode.OpenOrCreate, isf)) {
482                                         isfs.WriteByte (0);
483                                 }
484                                 string pattern = Path.Combine (dir, "*");
485                                 Assert.AreEqual (1, isf.GetFileNames (file).Length, "file exists");
486
487                                 // create again directory
488                                 isf.CreateDirectory (dir);
489                                 Assert.AreEqual (1, isf.GetFileNames (file).Length, "file still exists");
490                         }
491                         finally {
492                                 isf.DeleteFile (file);
493                                 isf.DeleteDirectory (dir);
494                         }
495                 }
496
497                 [Test]
498 #if NET_4_0 || NET_2_1
499                 [ExpectedException (typeof (ArgumentException))]
500 #else
501                 [ExpectedException (typeof (SecurityException))]
502 #endif
503                 public void GetFilesInSubdirs ()
504                 {
505                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
506                         string pattern = Path.Combine ("..", "*");
507                         isf.GetFileNames (pattern);
508                 }
509
510         
511 #if NET_4_0
512                 [Test]
513                 [ExpectedException (typeof (ArgumentException))]
514                 public void GetDirsInSubDirs ()
515                 {
516                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
517                         isf.CreateDirectory ("subdir");
518                         string [] dir_names = isf.GetDirectoryNames ("subdir/../*");
519                 }
520 #endif
521
522                 [Test] // https://bugzilla.novell.com/show_bug.cgi?id=376188
523                 public void CreateSubDirectory ()
524                 {
525                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
526                         isf.CreateDirectory ("subdir");
527                         isf.CreateDirectory ("subdir/subdir2");
528                         Assert.AreEqual (1, isf.GetDirectoryNames ("*").Length, "subdir");
529                         Assert.AreEqual (1, isf.GetDirectoryNames ("subdir/*").Length, "subdir/subdir2");
530                         isf.DeleteDirectory ("subdir/subdir2");
531                         isf.DeleteDirectory ("subdir");
532                 }
533
534                 [Test]
535                 [ExpectedException (typeof (IsolatedStorageException))]
536                 public void DeleteDirectory_NonEmpty ()
537                 {
538                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
539                         isf.CreateDirectory ("subdir");
540                         isf.CreateDirectory ("subdir/subdir2");
541                         isf.DeleteDirectory ("subdir");
542                 }
543
544                 [Test]
545                 public void DeleteFile ()
546                 {
547                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
548
549                         try {
550                                 isf.DeleteFile (null);
551                                 Assert.Fail ("#Exc0");
552                         } catch (ArgumentNullException) {
553                         }
554
555 #if NET_4_0
556                         // We are getting an internal IndexOutOfRangeException in 2.0
557                         // Not sure we want to mimic that one.
558                         try {
559                                 isf.DeleteFile (String.Empty);
560                                 Assert.Fail ("#Exc1");
561                         } catch (IsolatedStorageException) {
562                         }
563 #endif
564
565                         try {
566                                 isf.DeleteFile ("idontexist");
567                                 Assert.Fail ("#Exc2");
568                         } catch (IsolatedStorageException) {
569                         }
570
571 #if NET_4_0
572                         try {
573                                 isf.DeleteFile ("../../file");
574                                 Assert.Fail ("#Exc3");
575                         } catch (IsolatedStorageException) {
576                         }
577 #endif
578                 
579                         try {
580                                 isf.DeleteFile ("subdir/file");
581                                 Assert.Fail ("#Exc4");
582                         } catch (IsolatedStorageException) {
583                         }
584
585                         isf.CreateDirectory ("subdir");
586                         try {
587                                 isf.DeleteFile ("subdir");
588                                 Assert.Fail ("#Exc5");
589                         } catch (IsolatedStorageException) {
590                         }
591                 }
592
593                 [Test]
594                 public void GetStore_NullTypes ()
595                 {
596                         IsolatedStorageScope scope = IsolatedStorageScope.User | IsolatedStorageScope.Roaming | IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain;
597                         IsolatedStorageFile isf = IsolatedStorageFile.GetStore (scope, null, null);
598 #if !NET_2_1
599                         Assert.AreEqual (typeof (Url), isf.AssemblyIdentity.GetType (), "AssemblyIdentity");
600                         Assert.AreEqual (typeof (Url), isf.DomainIdentity.GetType (), "DomainIdentity");
601 #endif
602                 }
603
604                 [Test]
605                 public void RemoveFromOtherInstance ()
606                 {
607                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
608                         IsolatedStorageFile isf2 = IsolatedStorageFile.GetUserStoreForAssembly ();
609
610                         isf.Remove ();
611                         try {
612                                 isf2.Remove ();
613                                 Assert.Fail ("#Exc1");
614                         } catch (IsolatedStorageException) {
615                         }
616                 }
617
618 #if NET_4_0
619                 [Test]
620                 public void Remove ()
621                 {
622                         // Test that we can call Remove several times
623                         IsolatedStorageFile.Remove (IsolatedStorageScope.User);
624                         IsolatedStorageFile.Remove (IsolatedStorageScope.User);
625
626                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
627                         isf.Remove ();
628
629                         // The second call to Remove should cause an InvalidOperationException, due to
630                         // marking itself as closed.
631                         try {
632                                 isf.Remove ();
633                                 Assert.Fail ("#Exc1");
634                         } catch (InvalidOperationException) {
635                         }
636
637                         // Open, Close and try to Remove
638                         isf = IsolatedStorageFile.GetUserStoreForAssembly ();
639                         isf.Close ();
640                         try {
641                                 isf.Remove ();
642                                 Assert.Fail ("#Exc2");
643                         } catch (InvalidOperationException) {
644                         }
645                 }
646
647                 [Test]
648                 public void UsedSize ()
649                 {
650                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
651                         IsolatedStorageFileStream isfs = isf.CreateFile ("file");
652                         StreamWriter writer = new StreamWriter (isfs);
653                         writer.WriteLine ("hello mono");
654                         writer.Close ();
655
656                         Assert.AreEqual (true, isf.UsedSize > 0, "#A0");
657
658                         isf.Close ();
659                         try {
660                                 Console.WriteLine (isf.UsedSize);
661                                 Assert.Fail ("#Exc1");
662                         } catch (InvalidOperationException) {
663                         }
664
665                         isf.Dispose ();
666                         try {
667                                 Console.WriteLine (isf.UsedSize);
668                                 Assert.Fail ("#Exc2");
669                         } catch (ObjectDisposedException) {
670                         }
671                 }
672
673                 [Test]
674                 public void IncreateQuotaTo ()
675                 {
676                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
677
678                         try {
679                                 isf.IncreaseQuotaTo (-2);
680                                 Assert.Fail ("#Exc1");
681                         } catch (ArgumentException) {
682                         }
683
684                         // I wonder how this behaves on some systems
685                         try {
686                                 isf.IncreaseQuotaTo (100);
687                                 Assert.Fail ("#Exc2");
688                         } catch (ArgumentException) {
689                         }
690
691                         // Since 'Quota' seems to be returning Int64.MaxValue, we cannot truly test against a value
692                         // larger than that.
693                 }
694
695                 [Test]
696                 public void DirectoryExists ()
697                 {
698                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
699                         isf.CreateDirectory ("subdir");
700                         isf.CreateDirectory ("subdir/subdir2");
701                         isf.CreateDirectory ("subdir3");
702
703                         Assert.AreEqual (true, isf.DirectoryExists ("subdir/"), "#A0");
704                         Assert.AreEqual (true, isf.DirectoryExists ("subdir/subdir2/"), "#A1");
705                         Assert.AreEqual (true, isf.DirectoryExists ("subdir3"), "#A2");
706                         Assert.AreEqual (true, isf.DirectoryExists (String.Empty), "#A3"); // Weird
707                         Assert.AreEqual (false, isf.DirectoryExists ("subdir99"), "#A4");
708                         Assert.AreEqual (false, isf.DirectoryExists ("../../subdir"), "#A5");
709                         Assert.AreEqual (false, isf.DirectoryExists ("*"), "#A5");
710                         Assert.AreEqual (false, isf.DirectoryExists ("subdir*"), "#A6");
711
712                         isf.DeleteDirectory ("subdir3");
713                         Assert.AreEqual (false, isf.DirectoryExists ("subdir3"), "#B0");
714
715                         isf.DeleteDirectory ("subdir/subdir2");
716                         isf.DeleteDirectory ("subdir");
717
718                         try {
719                                 isf.DirectoryExists (null);
720                                 Assert.Fail ("#Exc1");
721                         } catch (ArgumentNullException) {
722                         }
723
724                         isf.Close ();
725                         try {
726                                 isf.DirectoryExists ("subdir");
727                                 Assert.Fail ("#Exc2");
728                         } catch (InvalidOperationException) {
729                         }
730
731                         isf.Dispose ();
732                         try {
733                                 isf.DirectoryExists ("subdir");
734                                 Assert.Fail ("#Exc3");
735                         } catch (ObjectDisposedException) {
736                         }
737
738                         // We want to be sure that if not closing but disposing
739                         // should fire ObjectDisposedException instead of InvalidOperationException
740                         isf = IsolatedStorageFile.GetUserStoreForAssembly ();
741                         isf.Dispose ();
742
743                         try {
744                                 isf.DirectoryExists ("subdir");
745                                 Assert.Fail ("#Exc4");
746                         } catch (ObjectDisposedException) {
747                         }
748                 }
749
750                 [Test]
751                 public void FileExists ()
752                 {
753                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
754                         IsolatedStorageFileStream file_a = new IsolatedStorageFileStream ("file-a", FileMode.Create, isf);
755                         IsolatedStorageFileStream file_b = new IsolatedStorageFileStream ("file-b", FileMode.Create, isf);
756                         file_a.Close ();
757                         file_b.Close ();
758
759                         Assert.AreEqual (true, isf.FileExists ("file-a"), "#A0");
760                         Assert.AreEqual (true, isf.FileExists ("file-b"), "#A1");
761                         Assert.AreEqual (false, isf.FileExists (String.Empty), "#A2");
762                         Assert.AreEqual (false, isf.FileExists ("file-"), "#A3");
763                         Assert.AreEqual (false, isf.FileExists ("file-*"), "#A4");
764                         Assert.AreEqual (false, isf.FileExists ("../../file-a"), "#A5");
765
766                         isf.CreateDirectory ("subdir");
767                         Assert.AreEqual (false, isf.FileExists ("subdir"), "#B0");
768
769                         try {
770                                 isf.FileExists (null);
771                                 Assert.Fail ("#Exc1");
772                         } catch (ArgumentNullException) {
773                         }
774
775                         isf.Close ();
776                         try {
777                                 isf.FileExists ("file-a");
778                                 Assert.Fail ("#Exc2");
779                         } catch (InvalidOperationException) {
780                         }
781
782                         isf.Dispose ();
783                         try {
784                                 isf.FileExists ("file-a");
785                                 Assert.Fail ("#Exc3");
786                         } catch (ObjectDisposedException) {
787                         }
788                 }
789
790                 [Test]
791                 public void CreateFile ()
792                 {
793                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
794                         // Make sure we are actually creating it, by first removing it in case it already exists
795                         if (isf.FileExists ("file-a"))
796                                 isf.DeleteFile ("file-a");
797
798                         IsolatedStorageFileStream isf_stream = isf.CreateFile ("file-a");
799                         isf_stream.Close ();
800                         Assert.AreEqual (true, isf.FileExists ("file-a"), "#A0");
801
802                         // Re-open the file that is already created, so we make sure we are passing
803                         // the proper FileOpen
804                         isf_stream = isf.CreateFile ("file-a");
805                         isf_stream.Close ();
806
807                         try {
808                                 isf.CreateFile (null);
809                                 Assert.Fail ("#Exc1");
810                         } catch (ArgumentNullException) {
811                         }
812
813                         try {
814                                 isf.CreateFile ("random-dir/fileb");
815                                 Assert.Fail ("#Exc2");
816                         } catch (DirectoryNotFoundException) {
817                         }
818
819                         isf.Close ();
820                         try {
821                                 isf.CreateFile ("file-b");
822                                 Assert.Fail ("#Exc3");
823                         } catch (InvalidOperationException) {
824                         }
825
826                         isf.Dispose ();
827                         try {
828                                 isf.CreateFile ("file-a");
829                                 Assert.Fail ("#Exc4");
830                         } catch (ObjectDisposedException) {
831                         }
832                 }
833
834                 [Test]
835                 public void GetCreationTime ()
836                 {
837                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
838
839                         // This is not causing an exception
840                         isf.GetCreationTime ("doesntexist");
841                         isf.GetCreationTime ("dir/doesntexist");
842
843                         try {
844                                 isf.GetCreationTime (String.Empty);
845                                 Assert.Fail ("#Exc1");
846                         } catch (ArgumentException) {
847                         }
848
849                         try {
850                                 isf.GetCreationTime ("   ");
851                                 Assert.Fail ("#Exc2");
852                         } catch (ArgumentException) {
853                         }
854
855                         isf.Close ();
856                         try {
857                                 isf.GetCreationTime ("doesntexist");
858                                 Assert.Fail ("#Exc3");
859                         } catch (InvalidOperationException) {
860                         }
861
862                         isf.Dispose ();
863                         try {
864                                 isf.GetCreationTime ("doesntexist");
865                                 Assert.Fail ("#Exc4");
866                         } catch (ObjectDisposedException) {
867                         }
868                 }
869
870                 [Test]
871                 public void MoveDirectory ()
872                 {
873                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
874                         // Mare sure to remove them if they exist already
875                         if (isf.DirectoryExists ("subdir"))
876                                 isf.DeleteDirectory ("subdir");
877                         if (isf.DirectoryExists ("subdir-new"))
878                                 isf.DeleteDirectory ("subdir-new");
879
880                         isf.CreateDirectory ("subdir");
881                         Assert.AreEqual (true, isf.DirectoryExists ("subdir"), "#A0");
882
883                         isf.MoveDirectory ("subdir", "subdir-new");
884                         Assert.AreEqual (false, isf.DirectoryExists ("subdir"), "#A1");
885                         Assert.AreEqual (true, isf.DirectoryExists ("subdir-new"), "#A2");
886
887                         try {
888                                 isf.MoveDirectory (String.Empty, "subdir-new-new");
889                                 Assert.Fail ("#Exc1");
890                         } catch (ArgumentException) {
891                         }
892
893                         try {
894                                 isf.MoveDirectory ("  ", "subdir-new-new");
895                                 Assert.Fail ("#Exc2");
896                         } catch (ArgumentException) {
897                         }
898
899                         try {
900                                 isf.MoveDirectory ("doesntexist", "subdir-new-new");
901                                 Assert.Fail ("#Exc3");
902                         } catch (DirectoryNotFoundException) {
903                         }
904
905                         try {
906                                 isf.MoveDirectory ("doesnexist/doesntexist", "subdir-new-new");
907                                 Assert.Fail ("#Exc4");
908                         } catch (DirectoryNotFoundException) {
909                         }
910
911                         try {
912                                 isf.MoveDirectory ("subdir-new", "doesntexist/doesntexist");
913                                 Assert.Fail ("#Exc5");
914                         } catch (DirectoryNotFoundException) {
915                         }
916
917                         // Out of storage dir
918                         try {
919                                 isf.MoveDirectory ("subdir-new", "../../subdir-new");
920                                 Assert.Fail ("#Exc6");
921                         } catch (IsolatedStorageException) {
922                         }
923
924                         isf.Remove ();
925                         isf.Close ();
926                         isf.Dispose ();
927                 }
928
929                 [Test]
930                 public void CopyFile ()
931                 {
932                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
933                         if (isf.FileExists ("file"))
934                                 isf.DeleteFile ("file");
935                         if (isf.FileExists ("file-new"))
936                                 isf.DeleteFile ("file-new");
937
938                         isf.CreateFile ("file").Close ();
939                         isf.CopyFile ("file", "file-new");
940                         Assert.AreEqual (true, isf.FileExists ("file"), "#A0");
941                         Assert.AreEqual (true, isf.FileExists ("file-new"), "#A1");
942
943                         // At this point 'file-exists' already exists.
944                         isf.CopyFile ("file", "file-new", true);
945                         Assert.AreEqual (true, isf.FileExists ("file"), "#B0");
946                         Assert.AreEqual (true, isf.FileExists ("file-new"), "#B1");
947
948                         isf.CreateDirectory ("subdir");
949                         isf.CreateFile ("subdir/subfile").Close ();
950                         isf.CopyFile ("subdir/subfile", "subdir/subfile-new");
951                         Assert.AreEqual (true, isf.FileExists ("subdir/subfile"), "#C0");
952                         Assert.AreEqual (true, isf.FileExists ("subdir/subfile-new"), "#C1");
953
954                         try {
955                                 isf.CopyFile ("file", "file-new");
956                                 Assert.Fail ("#Exc0");
957                         } catch (IsolatedStorageException) {
958                         }
959
960                         // Using the same file name is failing for even when passing override=true.
961                         try {
962                                 isf.CopyFile ("file-new", "file-new", true);
963                                 Assert.Fail ("#Exc1");
964                         } catch (IsolatedStorageException) {
965                         }
966
967                         try {
968                                 isf.CopyFile ("file-new", "file-new", false);
969                                 Assert.Fail ("#Exc2");
970                         } catch (IsolatedStorageException) {
971                         }
972
973                         // Remove 'file-new' for cleaness purposes.
974                         isf.DeleteFile ("file-new");
975
976                         try {
977                                 isf.CopyFile ("doesntexist", "file-new", false);
978                                 Assert.Fail ("#Exc3");
979                         } catch (FileNotFoundException) {
980                         }
981
982                         try {
983                                 isf.CopyFile ("doesnexist/doesntexist", "file-new", false);
984                                 Assert.Fail ("#Exc4");
985                         } catch (DirectoryNotFoundException) {
986                         }
987
988                         // I'd have expected a DirectoryNotFoundException here.
989                         try {
990                                 isf.CopyFile ("file", "doesntexist/doesntexist");
991                                 Assert.Fail ("#Exc5");
992                         } catch (IsolatedStorageException) {
993                         }
994
995                         // Out of storage dir
996                         try {
997                                 isf.CopyFile ("file", "../../file");
998                                 Assert.Fail ("#Exc6");
999                         } catch (IsolatedStorageException) {
1000                         }
1001
1002                         try {
1003                                 isf.CopyFile ("../file", "file-new");
1004                                 Assert.Fail ("#Exc7");
1005                         } catch (IsolatedStorageException) {
1006                         }
1007
1008                         // We are creating a subdirectory and files within it, so remove it just in case.
1009                         isf.Remove ();
1010
1011                         isf.Close ();
1012                         isf.Dispose ();
1013                 }
1014
1015                 [Test]
1016                 public void MoveFile ()
1017                 {
1018                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
1019                         // Mare sure to remove them if they exist already
1020                         if (isf.FileExists ("file"))
1021                                 isf.DeleteFile ("file");
1022                         if (isf.FileExists ("file-new"))
1023                                 isf.DeleteFile ("file-new");
1024                         if (isf.FileExists ("subdir/subfile"))
1025                                 isf.DeleteFile ("subdir/subfile");
1026                         if (isf.FileExists ("subdir/subfile-new"))
1027                                 isf.DeleteFile ("subdir/subfile-new");
1028
1029                         isf.CreateFile ("file").Close ();
1030                         Assert.AreEqual (true, isf.FileExists ("file"), "#A0");
1031
1032                         // Same file
1033                         isf.MoveFile ("file", "file");
1034                         Assert.AreEqual (true, isf.FileExists ("file"), "#A0-1");
1035
1036                         isf.MoveFile ("file", "file-new");
1037                         Assert.AreEqual (false, isf.FileExists ("file"), "#A1");
1038                         Assert.AreEqual (true, isf.FileExists ("file-new"), "#A2");
1039
1040                         isf.CreateDirectory ("subdir");
1041                         isf.CreateFile ("subdir/subfile").Close ();
1042                         isf.MoveFile ("subdir/subfile", "subdir/subfile-new");
1043                         Assert.AreEqual (false, isf.FileExists ("subdir/subfile"), "#B0");
1044                         Assert.AreEqual (true, isf.FileExists ("subdir/subfile-new"), "#B1");
1045
1046                         try {
1047                                 isf.MoveFile (String.Empty, "file-new-new");
1048                                 Assert.Fail ("#Exc1");
1049                         } catch (ArgumentException) {
1050                         }
1051
1052                         try {
1053                                 isf.MoveFile ("  ", "file-new-new");
1054                                 Assert.Fail ("#Exc2");
1055                         } catch (ArgumentException e) {
1056                                 Console.WriteLine (e);
1057                         }
1058
1059                         try {
1060                                 isf.MoveFile ("doesntexist", "file-new-new");
1061                                 Assert.Fail ("#Exc3");
1062                         } catch (FileNotFoundException) {
1063                         }
1064
1065                         // CopyFile is throwing a DirectoryNotFoundException here.
1066                         try {
1067                                 isf.MoveFile ("doesnexist/doesntexist", "file-new-new");
1068                                 Assert.Fail ("#Exc4");
1069                         } catch (FileNotFoundException) {
1070                         }
1071
1072                         // I'd have expected a DirectoryNotFoundException here.
1073                         try {
1074                                 isf.MoveFile ("file-new", "doesntexist/doesntexist");
1075                                 Assert.Fail ("#Exc5");
1076                         } catch (IsolatedStorageException) {
1077                         }
1078
1079                         // Out of storage dir
1080                         try {
1081                                 isf.MoveFile ("file-new", "../../file-new");
1082                                 Assert.Fail ("#Exc6");
1083                         } catch (IsolatedStorageException) {
1084                         }
1085
1086                         isf.Remove ();
1087                         isf.Close ();
1088                         isf.Dispose ();
1089                 }
1090
1091                 [Test]
1092                 public void MultiLevel ()
1093                 {
1094                         // see bug #4101
1095                         IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
1096                         try {
1097                                 isf.CreateDirectory ("dir1");
1098                                 string [] dirs = isf.GetDirectoryNames ("*");
1099                                 Assert.AreEqual (dirs.Length, 1, "1a");
1100                                 Assert.AreEqual (dirs [0], "dir1", "1b");
1101         
1102                                 isf.CreateDirectory ("dir1/test");
1103                                 dirs = isf.GetDirectoryNames ("dir1/*");
1104                                 Assert.AreEqual (dirs.Length, 1, "2a");
1105                                 Assert.AreEqual (dirs [0], "test", "2b");
1106         
1107                                 isf.CreateDirectory ("dir1/test/test2a");
1108                                 isf.CreateDirectory ("dir1/test/test2b");
1109                                 dirs = isf.GetDirectoryNames ("dir1/test/*");
1110                                 Assert.AreEqual (dirs.Length, 2, "3a");
1111                                 Assert.AreEqual (dirs [0], "test2a", "3b");
1112                                 Assert.AreEqual (dirs [1], "test2b", "3c");
1113                         }
1114                         finally {
1115                                 isf.DeleteDirectory ("dir1/test/test2a");
1116                                 isf.DeleteDirectory ("dir1/test/test2b");
1117                                 isf.DeleteDirectory ("dir1/test");
1118                                 isf.DeleteDirectory ("dir1");
1119                         }
1120                 }
1121 #endif
1122         }
1123 }