public void GetLastWriteTime_RaisesArgumentException() { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly()) { Assert.Throws<ArgumentException>(() => isf.GetLastWriteTime("\0bad")); } }
public void GetLastWriteTime_ThrowsArgumentNull() { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly()) { Assert.Throws<ArgumentNullException>(() => isf.GetLastWriteTime(null)); } }
public void GetLastWriteTime_Deleted_ThrowsInvalidOperationException() { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly()) { isf.Remove(); Assert.Throws<InvalidOperationException>(() => isf.GetLastWriteTime("foo")); } }
public void GetLastWriteTime_GetsTime() { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly()) { string file = "GetLastWriteTime_GetsTime"; isf.CreateTestFile(file); // Filesystem timestamps vary in granularity, we can't make a positive assertion that // the time will come before or after the current time. Assert.True(TestHelper.IsTimeCloseToNow(isf.GetLastWriteTime(file))); } }
private Collection<SearchableFile> getFiles(string pattern, IsolatedStorageFile storeFile, Collection<SearchableFile> list) { string root = System.IO.Path.GetDirectoryName(pattern); foreach (string fileName in storeFile.GetFileNames(pattern)) { string filePath = System.IO.Path.Combine(root, fileName); string fileText = string.Empty; using (StreamReader myReader = new StreamReader(new IsolatedStorageFileStream(filePath, FileMode.Open, storeFile))) { fileText = myReader.ReadToEnd(); } list.Add(new SearchableFile(filePath, fileName, root, storeFile.GetLastWriteTime(filePath), fileText)); } foreach (string dirName in storeFile.GetDirectoryNames(pattern)) { pattern = System.IO.Path.Combine(root, dirName); list = getFiles(pattern + "/*", storeFile, list); } return list; }
/// <summary> /// Determines the age of a file based on the last time it was written to /// </summary> /// <param name="filepath">The path of the file to test.</param> /// <param name="storage">A reference to a valid IsolatedStorageFile instance.</param> /// <returns>A DateTimeOffset indiciating the last valid file write date.</returns> public static DateTimeOffset GetFileAge(string filepath, IsolatedStorageFile storage) { return storage.GetLastWriteTime(filepath); }
public override Task <DateTimeOffset> GetLastWriteTimeAsync(string path) { return(Task <DateTimeOffset> .Factory.StartNew(() => (file.GetLastWriteTime(path)))); }