Beispiel #1
0
        private string AppendFileChecksum(string filePath)
        {
            var fullFilePath = _httpCtx.Server.MapPath(filePath);

            if (_memoryCacheService.Get <FileSystemWatcherBase>(fullFilePath + "-fsw") == null)
            {
                // Ensure a file system watcher exists
                var fsw = _fswSvc.CreateFileSystemWatcher(fullFilePath);
                fsw.NotifyFilter = NotifyFilters.LastWrite;
                fsw.Changed     += new FileSystemEventHandler(OnFileCreatedOrChanged);
                _memoryCacheService.Default[fullFilePath + "-fsw"] = fsw;
            }

            // Get or update
            return((string)(_memoryCacheService.Default[fullFilePath]
                            ?? (_memoryCacheService.Default[fullFilePath] = CalculateFileHash(fullFilePath))));
        }