0

我以编程方式创建了一个虚拟目录。现在我想上传一个 HTML 文件到创建的虚拟目录。我怎样才能做到这一点?

片段:

DirectoryEntry Rootdir =  new DirectoryEntry("IIS://localhost/W3SVC/1/Root");
DirectoryEntry dir= Rootdir .Children.Add("MyDirectory", "IIsWebVirtualDir");
Directory.CreateDirectory(Rootdir .Properties["Path"].Value+"\\MyDirectory");
dir.Properties["Path"].Insert(0, Rootdir .Properties["Path"].Value + "\\MyDirectory");
dir.CommitChanges();
Rootdir .CommitChanges();
dir.close();
Rootdir.close();
4

1 回答 1

0
FileInfo fileInfo = new FileInfo(@"C:\inetpub\wwwroot\iisstart.htm");
File.Copy(fileInfo.FullName, Rootdir.Properties["Path"].Value + "\\MyDirectory" + "\\" + fileInfo.Name);
于 2012-08-04T17:10:02.560 回答