我在多个IIS FTP站点(多个服务器2008-2019)的只写根文件夹下用C#创建子文件夹。当我创建子文件夹时,它从其根目录继承只写“ FTP授权”。如何更改新创建的子文件夹的FTP授权以使用C#进行读写?
这里是我如何将FTP授权规则添加到特定路径上的IIS FTP站点。
using (ServerManager serverManager = new ServerManager())
{
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection authorizationSection = config.GetSection("system.ftpServer/security/authorization", "FTP/LDNClient/Reports/" + itm["ftpClientName"]);
ConfigurationElementCollection authorizationCollection = authorizationSection.GetCollection();
ConfigurationElement addElement = authorizationCollection.CreateElement("add");
addElement["accessType"] = @"Allow";
addElement["users"] = @"LDNClient";
addElement["roles"] = @"";
addElement["permissions"] = @"Read, Write";
authorizationCollection.Add(addElement);
serverManager.CommitChanges();
}
其中“ FTP / LDNClient / Reports /” + itm [“ ftpClientName”]是我需要更新的路径。