主要内容

设置静态.NET属性

set system.environment.CurrentDirectory静态属性

此示例显示了如何使用该示例设置静态属性net.setstaticProperty.功能。

CurrentDirectory.物业在system.environment.类是静态,读/写属性。以下代码创建一个文件夹临时在当前文件夹中并更改CurrentDirectory.属性到新文件夹。

设置当前文件夹。

光盘('C:\工作'

设定CurrentDirectory.财产。

savedir = system.environment.CurrentDirectory;newdir = [char(savedir)'\ temp'];mkdir(newdir)net.setraticproperty('system.environment.currentdirectory',newdir)system.environment.CurrentDirectory
ans = c:\ work \ temp

恢复原文CurrentDirectory.价值。

net.setstaticProperty('system.environment.currentdirectory',Savedir)

不使用classname.propertyname.静态属性的语法

这个例子显示了如何错误地创建一个塑造数组而不是设置类属性。

如果你使用classname.propertyname.语法设置静态属性,matlab®创造一个塑造大批。

以下代码创建一个名为的结构系统

savedir = system.environment.CurrentDirectory;newdir = [char(savedir)'\ temp'];system.environment.currentdirectory = newdir;谁是
名称大小字节类系统1x1 376 struct newdir 1x12 24 char savedir 1x1 112 system.string

尝试使用成员系统命名空间。

olddate = system.datetime(1992,3,1);
参考不存在的字段'DateTime'。

要恢复环境,请键入:

清除系统net.setstaticProperty('system.environment.currentdirectory',Savedir)