Microsoft .NET Documentation
Represents the value of the File-Version HTTP header.
The File-Version header specifies the version of a file.
Initializes a new instance of the FileVersionHeaderValue class with the specified file and product versions.
Gets the file version string.
Gets the product version string.
Parses a string into a FileVersionHeaderValue instance.
Tries to parse a string into a FileVersionHeaderValue instance.
Returns the string representation of the FileVersionHeaderValue.
Determines whether the specified object is equal to the current object.
Serves as the default hash function.
Gets the type of the current instance.
Creates a shallow copy of the current object.
Here's how you might use the FileVersionHeaderValue class:
using System.Net.Http.Headers;
var fileVersion = new FileVersionHeaderValue("1.0.0.0", "MyApp/2.0");
Console.WriteLine(fileVersion.ToString());
// Output: FileVersion/1.0.0.0, ProductVersion/2.0
var headerString = "FileVersion/1.2.3.4, ProductVersion/MyLib/1.5";
if (FileVersionHeaderValue.TryParse(headerString, out FileVersionHeaderValue parsedValue))
{
Console.WriteLine($"Parsed File Version: {parsedValue.FileVersion}");
Console.WriteLine($"Parsed Product Version: {parsedValue.ProductVersion}");
}
else
{
Console.WriteLine("Failed to parse FileVersionHeaderValue.");
}
The FileVersionHeaderValue class is immutable once created. It implements the ICloneable interface.
FileVersion and ProductVersion are treated as strings and can contain various characters.ToString() method formats the header value according to the HTTP specification for the File-Version header.TryParse() for safe parsing to avoid exceptions when the input string is not in a valid format.| Parameter | Description |
|---|---|
fileVersion |
The file version string. This parameter cannot be null or empty. |
productVersion |
The product version string. This parameter can be null or empty. |
| Type | Description |
|---|---|
string |
The file version string. |
| Type | Description |
|---|---|
string |
The product version string. |
| Parameter | Description |
|---|---|
input |
The string to parse. |
| Type | Description |
|---|---|
FileVersionHeaderValue |
A FileVersionHeaderValue instance created from the input string. |
ArgumentNullException: Thrown if input is null.FormatException: Thrown if input is not in a valid format.| Parameter | Description |
|---|---|
input |
The string to parse. |
parsedValue |
When this method returns, contains the parsed FileVersionHeaderValue if the parse succeeded, or null otherwise. |
| Type | Description |
|---|---|
bool |
true if the string was parsed successfully; otherwise, false. |
| Type | Description |
|---|---|
string |
The string representation of the header value. |
| Parameter | Description |
|---|---|
obj |
The object to compare with the current object. |
| Type | Description |
|---|---|
bool |
true if the specified object is equal to the current object; otherwise, false. |
| Type | Description |
|---|---|
int |
A hash code for the current object. |
| Type | Description |
|---|---|
Type |
A Type instance representing the current object. |
| Type | Description |
|---|---|
object |
A shallow copy of the current object. |