GetLastWriteTime() public method

public GetLastWriteTime ( string path ) : DateTimeOffset
path string
return DateTimeOffset
コード例 #1
0
 public void GetLastWriteTime_RaisesArgumentException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         Assert.Throws<ArgumentException>(() => isf.GetLastWriteTime("\0bad"));
     }
 }
コード例 #2
0
 public void GetLastWriteTime_ThrowsArgumentNull()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         Assert.Throws<ArgumentNullException>(() => isf.GetLastWriteTime(null));
     }
 }
コード例 #3
0
 public void GetLastWriteTime_Deleted_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws<InvalidOperationException>(() => isf.GetLastWriteTime("foo"));
     }
 }
コード例 #4
0
        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)));
            }
        }
コード例 #5
0
ファイル: Searcher.cs プロジェクト: hmehart/Notepad
        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);
 }
コード例 #7
0
 public override Task <DateTimeOffset> GetLastWriteTimeAsync(string path)
 {
     return(Task <DateTimeOffset> .Factory.StartNew(() => (file.GetLastWriteTime(path))));
 }