我以编程方式创建了一个虚拟目录。现在我想将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();
答案 0 :(得分:0)
FileInfo fileInfo = new FileInfo(@"C:\inetpub\wwwroot\iisstart.htm");
File.Copy(fileInfo.FullName, Rootdir.Properties["Path"].Value + "\\MyDirectory" + "\\" + fileInfo.Name);