比如我把文件上传到自己的服务器后,如何实现,让自己服务器的文件自动传到另一台服务器上

解决方案 »

  1.   

    这个是我自己做的,应该没有什么大问题,自己看看.
    namespace VideoSample.上传
    {
    /// <summary>
    /// inputFile 的摘要说明。
    /// </summary>
    public class inputFile : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Button btnUpLoad;
    protected System.Web.UI.HtmlControls.HtmlInputFile File1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.btnUpLoad.Click += new System.EventHandler(this.btnUpLoad_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void btnUpLoad_Click(object sender, System.EventArgs e)
    {
    string fullfileName=this.File1.PostedFile.FileName;
    string fileName=fullfileName.Substring(fullfileName.LastIndexOf("\\")+1);
    this.File1.PostedFile.SaveAs(Server.MapPath("up")+"\\"+fileName);
    }
    }
    }
      

  2.   

    试下这个方法可以不:
    =============
    利用SQL移动硬盘文件if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_movefile]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
    drop procedure [dbo].[p_movefile]
    GO/*--移动服务器上的文件 不借助 xp_cmdshell ,因为这个在大多数时候都被禁用了--邹建 2004.08(引用请保留此信息)--*//*--调用示例 exec p_movefile 'd:\aa.txt','c:\'
    --*/
    create proc p_movefile
    @s_file varchar(1000), --源文件
    @d_file varchar(1000) --目标文件
    as
    declare @err int,@src varchar(255),@desc varchar(255)
    declare @obj intexec @err=sp_oacreate 'Scripting.FileSystemObject',@obj out
    if @err<>0 goto lberrexec @err=sp_oamethod @obj,'MoveFile',null,@s_file,@d_file
    if @err<>0 goto lberrexec @err=sp_oadestroy @obj
    returnlberr:
     exec sp_oageterrorinfo 0,@src out,@desc out
     select cast(@err as varbinary(4)) as 错误号
      ,@src as 错误源,@desc as 错误描述
    go拷貝文件就是將MoveFile 改成CopyFile就可以了。