AppDomain.BaseDirectory 属性
获取基目录,它由程序集冲突解决程序用来探测程序集。
**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)
语法
声明
Public ReadOnly Property BaseDirectory As String
用法
Dim instance As AppDomain
Dim value As String
value = instance.BaseDirectory
public string BaseDirectory { get; }
public:
virtual property String^ BaseDirectory {
String^ get () sealed;
}
/** @property */
public final String get_BaseDirectory ()
public final function get BaseDirectory () : String
属性值
基目录,由程序集冲突解决程序用来探测程序集。
异常
异常类型 | 条件 |
---|---|
试图对已卸载的应用程序域进行操作。 |
备注
此属性与程序集冲突解决程序的 APPBASE 对应。
示例
Imports System
Imports System.Reflection
Imports System.Security.Policy
'for evidence object
Class ADSetup
Public Shared Sub Main()
' Create the application domain setup information.
Dim domaininfo As New AppDomainSetup()
domaininfo.ConfigurationFile = "file:///" + System.Environment.CurrentDirectory + "ADSetup.exe.config"
domaininfo.ApplicationBase = "file:///" + System.Environment.CurrentDirectory
'Create evidence for the new appdomain from evidence of the current application domain.
Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence
' Create appdomain.
Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo)
' Write out the application domain information.
Console.WriteLine(("Host domain: " + AppDomain.CurrentDomain.FriendlyName))
Console.WriteLine(("child domain: " + domain.FriendlyName))
Console.WriteLine()
Console.WriteLine(("Configuration file is: " + domain.SetupInformation.ConfigurationFile))
Console.WriteLine(("Application Base Directory is: " + domain.BaseDirectory))
AppDomain.Unload(domain)
End Sub 'Main
End Class 'ADSetup
using System;
using System.Reflection;
using System.Security.Policy; //for evidence object
class ADSetup
{
public static void Main()
{
// Create application domain setup information
AppDomainSetup domaininfo = new AppDomainSetup();
domaininfo.ConfigurationFile = "file:///" + System.Environment.CurrentDirectory + "ADSetup.exe.config";
domaininfo.ApplicationBase = "file:///" + System.Environment.CurrentDirectory;
//Create evidence for the new appdomain from evidence of the current application domain
Evidence adevidence = AppDomain.CurrentDomain.Evidence;
// Create appdomain
AppDomain domain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo);
// Write out application domain information
Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
Console.WriteLine("child domain: " + domain.FriendlyName);
Console.WriteLine();
Console.WriteLine("Configuration file is: " + domain.SetupInformation.ConfigurationFile);
Console.WriteLine("Application Base Directory is: " + domain.BaseDirectory);
AppDomain.Unload(domain);
}
}
using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;
//for evidence Object
int main()
{
// Create application domain setup information
AppDomainSetup^ domaininfo = gcnew AppDomainSetup;
domaininfo->ConfigurationFile = String::Format( "file:///{0}ADSetup.exe.config", System::Environment::CurrentDirectory );
domaininfo->ApplicationBase = String::Format( "file:///{0}", System::Environment::CurrentDirectory );
//Create evidence for the new appdomain from evidence of the current application domain
Evidence^ adevidence = AppDomain::CurrentDomain->Evidence;
// Create appdomain
AppDomain^ domain = AppDomain::CreateDomain( "MyDomain", adevidence, domaininfo );
// Write out application domain information
Console::WriteLine( "Host domain: {0}", AppDomain::CurrentDomain->FriendlyName );
Console::WriteLine( "child domain: {0}", domain->FriendlyName );
Console::WriteLine();
Console::WriteLine( "Configuration file is: {0}", domain->SetupInformation->ConfigurationFile );
Console::WriteLine( "Application Base Directory is: {0}", domain->BaseDirectory );
AppDomain::Unload( domain );
}
import System.*;
import System.Reflection.*;
import System.Security.Policy.*; //for evidence object
class ADSetup
{
public static void main(String[] args)
{
// Create application domain setup information
AppDomainSetup domainInfo = new AppDomainSetup();
domainInfo.set_ConfigurationFile("file:///"
+ System.Environment.get_CurrentDirectory() + "ADSetup.exe.config");
domainInfo.set_ApplicationBase("file:///"
+ System.Environment.get_CurrentDirectory());
// Create evidence for the new appdomain from evidence of the
// current application domain
Evidence adEvidence = AppDomain.get_CurrentDomain().get_Evidence();
// Create appdomain
AppDomain domain = AppDomain.CreateDomain("MyDomain", adEvidence,
domainInfo);
// Write out application domain information
Console.WriteLine("Host domain: "
+ AppDomain.get_CurrentDomain().get_FriendlyName());
Console.WriteLine("child domain: "
+ domain.get_FriendlyName());
Console.WriteLine();
Console.WriteLine("Configuration file is: "
+ domain.get_SetupInformation().get_ConfigurationFile());
Console.WriteLine("Application Base Directory is: "
+ domain.get_BaseDirectory());
AppDomain.Unload(domain);
} //main
} //ADSetup
.NET Framework 安全性
- FileIOPermission 用于从文件或目录中读取以及访问路径本身中的信息(包括路径是否为“file://”、\\UNC\dir 或“c:\”形式)。关联的枚举:FileIOPermissionAccess.Read、FileIOPermissionAccess.PathDiscovery。
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0