Configuration.HasFile Configuration.HasFile Configuration.HasFile Configuration.HasFile Property

定义

获取一个值,该值指示由此 Configuration 对象表示的资源是否存在相应的文件。Gets a value that indicates whether a file exists for the resource represented by this Configuration object.

public:
 property bool HasFile { bool get(); };
public bool HasFile { get; }
member this.HasFile : bool
Public ReadOnly Property HasFile As Boolean

属性值

如果该配置文件存在,则为 true;否则,为 falsetrue if there is a configuration file; otherwise, false.

示例

下面的代码示例演示如何使用HasFile属性。The following code example demonstrates how to use the HasFile property.

bool hasFile = config.HasFile;
Console.WriteLine("Has file: {0}", hasFile.ToString());
Dim hasFile As Boolean = config.HasFile
Console.WriteLine("Has file: {0}", hasFile.ToString())

注解

HasFile true由此对象Configuration表示的资源从 web.config 文件中继承设置时,属性也将返回。The HasFile property also returns true when the resource represented by this Configuration object inherits settings from a Web.config file.

HasFile false此对象Configuration表示特定于位置的配置时,属性将返回。The HasFile property returns false when this Configuration object represents a location-specific configuration.

适用于