private static readonly Mutex mutex = new Mutex ();
#endif
-#if NET_4_0
private bool closed;
private bool disposed;
-#endif
public static IEnumerator GetEnumerator (IsolatedStorageScope scope)
{
return storageFile;
}
-#if NET_4_0
[ComVisible (false)]
public static IsolatedStorageFile GetUserStoreForSite ()
{
throw new NotSupportedException ();
}
-#endif
public static void Remove (IsolatedStorageScope scope)
{
}
[CLSCompliant(false)]
-#if NET_4_0
[Obsolete]
-#endif
public override ulong CurrentSize {
get { return GetDirectorySize (directory); }
}
[CLSCompliant(false)]
-#if NET_4_0
[Obsolete]
-#endif
public override ulong MaximumSize {
// return an ulong but default is signed long
get {
get { return directory.FullName; }
}
-#if NET_4_0
[ComVisible (false)]
public override long AvailableFreeSpace {
get {
return disposed;
}
}
-#endif
// methods
public void Close ()
{
-#if NET_4_0
closed = true;
-#endif
}
public void CreateDirectory (string dir)
if (dir.IndexOfAny (Path.PathSeparatorChars) < 0) {
if (directory.GetFiles (dir).Length > 0)
-#if NET_4_0
throw new IsolatedStorageException ("Unable to create directory.");
-#else
- throw new IOException (Locale.GetText ("Directory name already exists as a file."));
-#endif
directory.CreateSubdirectory (dir);
} else {
string[] dirs = dir.Split (Path.PathSeparatorChars, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < dirs.Length; i++) {
if (dinfo.GetFiles (dirs [i]).Length > 0)
-#if NET_4_0
throw new IsolatedStorageException ("Unable to create directory.");
-#else
- throw new IOException (Locale.GetText (
- "Part of the directory name already exists as a file."));
-#endif
dinfo = dinfo.CreateSubdirectory (dirs [i]);
}
}
}
-#if NET_4_0
[ComVisible (false)]
public void CopyFile (string sourceFileName, string destinationFileName)
{
{
return new IsolatedStorageFileStream (path, FileMode.Create, FileAccess.ReadWrite, FileShare.None, this);
}
-#endif
public void DeleteDirectory (string dir)
{
public void Dispose ()
{
-#if NET_4_0
// Dispose may be calling Close, but we are not sure
disposed = true;
-#endif
// nothing to dispose, anyway we want to please the tools
GC.SuppressFinalize (this);
}
-#if NET_4_0
[ComVisible (false)]
public bool DirectoryExists (string path)
{
return Directory.GetLastWriteTime (full_path);
}
-#endif
public string[] GetDirectoryNames (string searchPattern)
{
if (searchPattern == null)
throw new ArgumentNullException ("searchPattern");
-#if NET_4_0
if (searchPattern.Contains (".."))
throw new ArgumentException ("Search pattern cannot contain '..' to move up directories.", "searchPattern");
-#endif
// note: IsolatedStorageFile accept a "dir/file" pattern which is not allowed by DirectoryInfo
// so we need to split them to get the right results
return GetNames (adi);
}
-#if NET_4_0
[ComVisible (false)]
public string [] GetDirectoryNames ()
{
return GetDirectoryNames ("*");
}
-#endif
private string[] GetNames (FileSystemInfo[] afsi)
{
{
if (searchPattern == null)
throw new ArgumentNullException ("searchPattern");
-#if NET_4_0
if (searchPattern.Contains (".."))
throw new ArgumentException ("Search pattern cannot contain '..' to move up directories.", "searchPattern");
-#endif
// note: IsolatedStorageFile accept a "dir/file" pattern which is not allowed by DirectoryInfo
// so we need to split them to get the right results
return GetNames (afi);
}
-#if NET_4_0
[ComVisible (false)]
public string [] GetFileNames ()
{
{
return new IsolatedStorageFileStream (path, mode, access, share, this);
}
-#endif
public override void Remove ()
{
-#if NET_4_0
CheckOpen (false);
-#endif
try {
directory.Delete (true);
} catch {
}
// internal stuff
-#if NET_4_0
void CheckOpen ()
{
CheckOpen (true);
{
return Path.GetFullPath (path).StartsWith (directory.FullName);
}
-#endif
#if !MOBILE
private string GetNameFromIdentity (object identity)