Icon Constructor (String, Size)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the Icon class of the specified size from the specified file.

Namespace:   System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public Icon(
	string fileName,
	Size size
)

Parameters

fileName
Type: System.String

The name and path to the file that contains the icon data.

size
Type: System.Drawing.Size

The desired size of the icon.

Exception Condition
ArgumentException

The string is null or does not contain image data.

If the specified file does not contain an image that matches the desired size, the icon that has the closest size is returned.

The fileName should include the complete path if it is not in the current application directory.

.NET Framework
Available since 2.0
Return to top
Show: