如何使用c# .net 2.0将我的文件夹转换为应用程序
本文关键字:文件夹 我的 转换 应用程序 何使用 net | 更新日期: 2023-09-27 18:07:35
我在IIS中有我的项目(文件夹格式),我想将该文件夹转换为应用程序(如右键单击->转换为应用程序),我想在c#代码中执行此操作,我使用。net 2.0。我遵循这个链接使用ServerManager在应用程序中创建应用程序,但我不知道
Site site = serverManager.Sites.First(s => s.Id == 3);
那是什么?当我尝试添加该代码时,我得到的错误称为:microsoft.web.administration。sitecollection不包含第一个
的定义那是什么?
它是LINQ
,在。net 2.0中不可用。您将需要使用。net 3.5或更高版本,并在项目中引用System.Core
程序集,并将System.Linq
命名空间添加到using
指令中,以便将.First()
扩展方法纳入范围。
如果你不能升级到。net的最新版本,你可以使用以下命令获得类似的结果:
Site site = null;
foreach (var s in serverManager.Sites)
{
if (s.Id == 3)
{
site = s;
break;
}
}
if (site == null)
{
throw new InvalidOperationException("Sequence contains no elements that match the criteria (Site Id = 3)");
}
// at this stage you could use the site variable.