/// <summary> /// Deletes a file. /// </summary> /// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param> /// <param name="fileName">The file to delete.</param> public void Delete(String containerName, String fileName, FileLocationContainer container) { if (container.HasFlag(FileLocationContainer.SavedGames) || container.HasFlag(FileLocationContainer.Title)) { throw new InvalidOperationException("Can not search in other containers than IsolatedStorage"); } using (IsolatedStorageFile storage = GetIsolatedStorage(container)) { #if SILVERLIGHT while (!this.IsReady || this.IsBusy) { Thread.SpinWait(1000); } Thread.MemoryBarrier(); #else SpinWait.SpinUntil(() => { System.Threading.Thread.MemoryBarrier(); return(this.IsReady && !this.IsBusy); }); #endif if (FileExists(containerName, fileName, container)) { storage.DeleteFile(String.Join("/", containerName, fileName)); } } }
/// <summary> /// Gets an array of all files available in a container. /// </summary> /// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param> /// <param name="pattern">A search pattern to use to find files.</param> /// <returns>An array of file names of the files in the container.</returns> public String[] GetFiles(String containerName, String pattern, FileLocationContainer container) { if (container.HasFlag(FileLocationContainer.SavedGames) || container.HasFlag(FileLocationContainer.Title)) { throw new InvalidOperationException("Can not search in other containers than IsolatedStorage"); } using (IsolatedStorageFile storage = GetIsolatedStorage(container)) { return(storage.GetFileNames(pattern)); } }
/// <summary> /// Determines if a given file exists. /// </summary> /// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param> /// <param name="fileName">The name of the file.</param> /// <returns>True if the file exists, false otherwise.</returns> public bool FileExists(String containerName, String fileName, FileLocationContainer container) { if (container.HasFlag(FileLocationContainer.SavedGames) || container.HasFlag(FileLocationContainer.Title)) { throw new InvalidOperationException("Can not search in other containers than IsolatedStorage"); } using (IsolatedStorageFile storage = GetIsolatedStorage(container)) { return(storage.FileExists(String.Join("/", containerName, fileName))); } }
/// <summary> /// Loads a file. /// </summary> /// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param> /// <param name="fileName">The file to load.</param> /// <param name="loadAction">The load action to perform.</param> public void Load(String containerName, String fileName, FileAction loadAction, FileLocationContainer container) { if (container.HasFlag(FileLocationContainer.SavedGames) || container.HasFlag(FileLocationContainer.Title)) { throw new InvalidOperationException("Can not search in other containers than IsolatedStorage"); } using (IsolatedStorageFile storage = GetIsolatedStorage(container)) { SpinWait.SpinUntil(() => { System.Threading.Thread.MemoryBarrier(); return(this.IsReady && !this.IsBusy); }); using (var stream = storage.OpenFile(String.Join("/", containerName, fileName), FileMode.Open)) { loadAction(stream); } } }
/// <summary> /// Gets an array of all files available in a container. /// </summary> /// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param> /// <param name="pattern">A search pattern to use to find files.</param> /// <returns>An array of file names of the files in the container.</returns> public String[] GetFiles(String containerName, String pattern, FileLocationContainer container) { if (container.HasFlag(FileLocationContainer.SavedGames) || container.HasFlag(FileLocationContainer.Title)) throw new InvalidOperationException("Can not search in other containers than IsolatedStorage"); using (IsolatedStorageFile storage = GetIsolatedStorage(container)) { return storage.GetFileNames(pattern); } }
/// <summary> /// Determines if a given file exists. /// </summary> /// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param> /// <param name="fileName">The name of the file.</param> /// <returns>True if the file exists, false otherwise.</returns> public bool FileExists(String containerName, String fileName, FileLocationContainer container) { if (container.HasFlag(FileLocationContainer.SavedGames) || container.HasFlag(FileLocationContainer.Title)) throw new InvalidOperationException("Can not search in other containers than IsolatedStorage"); using (IsolatedStorageFile storage = GetIsolatedStorage(container)) { return storage.FileExists(String.Join("/", containerName, fileName)); } }
/// <summary> /// Deletes a file. /// </summary> /// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param> /// <param name="fileName">The file to delete.</param> public void Delete(String containerName, String fileName, FileLocationContainer container) { if (container.HasFlag(FileLocationContainer.SavedGames) || container.HasFlag(FileLocationContainer.Title)) throw new InvalidOperationException("Can not search in other containers than IsolatedStorage"); using (IsolatedStorageFile storage = GetIsolatedStorage(container)) { #if SILVERLIGHT while (!this.IsReady || this.IsBusy) Thread.SpinWait(1000); Thread.MemoryBarrier(); #else SpinWait.SpinUntil(() => { System.Threading.Thread.MemoryBarrier(); return this.IsReady && !this.IsBusy; }); #endif if (FileExists(containerName, fileName, container)) { storage.DeleteFile(String.Join("/", containerName, fileName)); } } }
/// <summary> /// Loads a file. /// </summary> /// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param> /// <param name="fileName">The file to load.</param> /// <param name="loadAction">The load action to perform.</param> public void Load(String containerName, String fileName, FileAction loadAction, FileLocationContainer container) { if (container.HasFlag(FileLocationContainer.SavedGames) || container.HasFlag(FileLocationContainer.Title)) throw new InvalidOperationException("Can not search in other containers than IsolatedStorage"); using (IsolatedStorageFile storage = GetIsolatedStorage(container)) { SpinWait.SpinUntil(() => { System.Threading.Thread.MemoryBarrier(); return this.IsReady && !this.IsBusy; }); using (var stream = storage.OpenFile(String.Join("/", containerName, fileName), FileMode.Open)) { loadAction(stream); } } }