NServiceBus.NonLockingFileReader.ReadAllTextWithoutLocking C# (CSharp) Method

ReadAllTextWithoutLocking() static private method

static private ReadAllTextWithoutLocking ( string path ) : string
path string
return string
        internal static string ReadAllTextWithoutLocking(string path)
        {
            using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (var textReader = new StreamReader(fileStream))
                {
                    return textReader.ReadToEnd();
                }
            }
        }
    }

Usage Example

Example #1
0
        /// <summary>
        /// Allows user to specify the path for the license file.
        /// </summary>
        /// <param name="config">The current <see cref="BusConfiguration"/>.</param>
        /// <param name="licenseFile">A relative or absolute path to the license file.</param>
        public static void LicensePath(this BusConfiguration config, string licenseFile)
        {
            if (!File.Exists(licenseFile))
            {
                throw new FileNotFoundException("License file not found", licenseFile);
            }

            var licenseText = NonLockingFileReader.ReadAllTextWithoutLocking(licenseFile);

            config.License(licenseText);
        }
All Usage Examples Of NServiceBus.NonLockingFileReader::ReadAllTextWithoutLocking
NonLockingFileReader