HasFile Property

Configuration.HasFile Property

Gets a value that indicates whether a file exists for the resource represented by this Configuration object.

Namespace: System.Configuration
Assembly: System.Configuration (in system.configuration.dll)

public bool HasFile { get; }
/** @property */
public boolean get_HasFile ()

public function get HasFile () : boolean

Not applicable.

Property Value

true if there is a configuration file; otherwise, false.

The HasFile property also returns true when the resource represented by this Configuration object inherits settings from a Web.config file.

The HasFile property returns false when this Configuration object represents a location-specific configuration.

The following code example demonstrates how to use the HasFile property.

bool hasFile = config.HasFile;
Console.WriteLine("Has file: {0}",

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

© 2016 Microsoft