Pretzel.Logic.Templating.Context.SiteContextGenerator.SafeReadLine C# (CSharp) Method

SafeReadLine() private method

private SafeReadLine ( string file ) : string
file string
return string
        private string SafeReadLine(string file)
        {
            string postFirstLine;
            try
            {
                using (var reader = fileSystem.File.OpenText(file))
                {
                    postFirstLine = reader.ReadLine();
                }
            }
            catch (IOException)
            {
                if (SanityCheck.IsLockedByAnotherProcess(file))
                {
                    Tracing.Info(String.Format("File {0} is locked by another process. Skipping", file));
                    return string.Empty;
                }

                var fileInfo = fileSystem.FileInfo.FromFileName(file);
                var tempFile = Path.Combine(Path.GetTempPath(), fileInfo.Name);
                try
                {
                    fileInfo.CopyTo(tempFile, true);
                    using (var streamReader = fileSystem.File.OpenText(tempFile))
                    {
                        return streamReader.ReadLine();
                    }
                }
                finally
                {
                    if (fileSystem.File.Exists(tempFile))
                        fileSystem.File.Delete(tempFile);
                }
            }
            return postFirstLine;
        }