コード例 #1
0
        public byte[] Read(string filename)
        {
            // Debug.WriteLine("Storage: Reading " + filename);

            byte[] bytes = new byte[] { };;
            // Opening for read only.
            try
            {
                if (IsoStore.FileExists(filename))
                {
                    using (var fileStream = IsoStore.OpenFile(filename, FileMode.Open, FileAccess.Read))
                    {
                        bytes = new byte[fileStream.Length];
                        fileStream.Read(bytes, 0, bytes.Length);
                    }
                }
            }
            catch (FileNotFoundException)
            {
            }
            catch (IsolatedStorageException)
            {
            }

            /*finally
             * {
             * }*/
            return(bytes);
        }
コード例 #2
0
ファイル: Logger.cs プロジェクト: Oxidda/Kamina
        private static string TryGetFileName()
        {
            string dateTimeAsString = DateTime.Now.Ticks.ToString();
            string logLine          = $"Log{dateTimeAsString}.txt";

            if (IsoStore.FileExists("Log.txt"))
            {
                if (!IsoStore.FileExists(logLine))
                {
                    IsoStore.CopyFile("Log.txt", logLine);
                }
                else
                {
                    return(TryGetFileName());
                }
            }
            return(logLine);
        }
コード例 #3
0
        public override byte[] Read(CacheItemInfo item)
        {
            var fi = new FileItem(item);

            byte[] bytes = null;

            lock (LockObject) {
                if (!IsoStore.FileExists(fi.FileName))
                {
                    return(null);
                }

                using (Stream stream = IsoStore.OpenFile(fi.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                    bytes = new byte[stream.Length];
                    stream.Read(bytes, 0, (int)stream.Length);
                }
            }

            return(bytes);
        }