日期:2014-05-20  浏览次数:20743 次

关于虚拟目录的问题,救命啊~~~~
1)我现在要在remote机器上面的iis下面建立一个virtual   directroy.
请问这个可行嘛?可行的话要怎么作??
2)接着上面,我如果要把文件上传到那个目录里面去,可行瓦?如果可行怎么作.
我快疯掉了

------解决方案--------------------
1,如果有权限的话,可行,网上关于C#操作IIS的文章很多
2.可行,在建立虚拟目录时设其可写!
------解决方案--------------------
转贴
-----------------------------------
C#在IIS里新建一个虚拟目录
DirectoryEntry dirE=new DirectoryEntry( "IIS://localhost/W3SVC/1/Root ");
DirectoryEntry newvirdir=dirE.Children.Add(d_name, "IIsWebVirtualDir ");
newvirdir.Invoke( "AppCreate ",true);
newvirdir.CommitChanges();
dirE.CommitChanges();

//配置虚拟目录的属性
newvirdir.Properties[ "AnonymousUserName "][0] = vd.AnonymousUserName;
newvirdir.Properties[ "AnonymousUserPass "][0] = vd.AnonymousUserPass;
newvirdir.Properties[ "AccessRead "][0] = vd.AccessRead;
newvirdir.Properties[ "AccessExecute "][0] = vd.AccessExecute;
newvirdir.Properties[ "AccessWrite "][0] = vd.AccessWrite;
newvirdir.Properties[ "AuthBasic "][0] = vd.AuthBasic;
newvirdir.Properties[ "AuthNTLM "][0] = vd.AuthNTLM;
newvirdir.Properties[ "ContentIndexed "][0] = vd.ContentIndexed;
newvirdir.Properties[ "EnableDefaultDoc "][0] = vd.EnableDefaultDoc;
newvirdir.Properties[ "EnableDirBrowsing "][0] = vd.EnableDirBrowsing;
newvirdir.Properties[ "AccessSSL "][0] = vd.AccessSSL;
newvirdir.Properties[ "AccessScript "][0] = vd.AccessScript;
newvirdir.Properties[ "DefaultDoc "][0] = vd.DefaultDoc;
newvirdir.Properties[ "Path "][0] = vd.Path;
newvirdir.CommitChanges();
------解决方案--------------------
看看这个
http://blog.csdn.net/jetxia/archive/2006/01/25/588028.aspx
------解决方案--------------------
帮顶
------解决方案--------------------
up
------解决方案--------------------

///***********************************************************
///************** IIS控制管理类 1.0 Beta **************
///************** Author: 飞刀 **************
///**************http://www.aspcn.com **************
///************** feidao@aspcn.com **************
///************** 2002.05.25 世界杯前6 天 **************
///***********************************************************
using System;
using System.Data;
using System.DirectoryServices;
using System.Collections;
namespace Aspcn.Management
{
/// <summary>
/// IISManager 的摘要说明。
/// </summary>
public class IISManager
{
//定义需要使用的
private string _server,_website;
private VirtualDirectories _virdirs;
protected System.DirectoryServices.DirectoryEntry rootfolder;
private bool _batchflag;
public IISManager()
{
//默认情况下使用localhost,即访问本地机
_server = "localhost ";
_website = "1 ";
_batchflag = false;
}
public IISManager(string strServer)
{
_server = strServer;
_website = "1 ";
_batchflag = false;
}
/// <summary>
/// 定义公共属性
/// </summary>

//Server属性定义访问机器的名字,可以是IP与计算名
public string Server
{
get{ return _server;}
set{ _server = value;}
}
//WebSite属性定义,为一数字,为方便,使用string
//一般来说第一台主机为1,第二台主机为2,依次类推