winform可以通過指定電腦IP、用戶名和密碼直接發送文件到指定IP電腦的指定文件夾裏嗎?求高手啊,求代碼

解决方案 »

  1.   

    只要你网络通,怎么不行,socket
      

  2.   

    可以利用FTP
    参考资料:http://www.cnblogs.com/aierong/archive/2008/12/08/ftp.html
      

  3.   

    高手Show幾段代碼來看看咯(最好是目標電腦上不用運行接收程序的)
      

  4.   

    你是要搞木马吧,,,,去百度啊,大把的SOCKET资料
      

  5.   


    /// <summary>
        ///  审核成功后发送附件到FTP:IP:219.151.8.75  用户名:bygtzy  密码bygtzy123  
        /// </summary>以FTP方式实现文件 的上传,需求FTP服务器
        /// <param name="localFile">形如 Server.MapPath("~/")+"log.txt"</param>
        /// <param name="dr">ftp服务器端目录名称,形如/vagerent/image/</param>
        /// <param name="newRemoteFile">传到服务器后的文件名称,比如log.txt</param>
        /// <returns></returns>
        private string FtpFile()
        {
            string strFromName = ddlWorkerId.SelectedItem.Text.ToString();//发件人
            string strTitleName = txtTitle.Text.ToString();//公告标题
            string strContentName = txtContent.Text.ToString();//公告备注
            string strPathName = Session["Path"].ToString();//获取附件名
            string strTypesName = ddlNoticeType.SelectedItem.Text.ToString();//公告类别
       ////////////////////////////////////////////////////////////////////////////////////
            string strFileNames = "";
            strFileNames = Session["Path"].ToString();//获取文件名
            string localFile = Server.MapPath("../Upfile/News/")+ strFileNames ;
            string remoteDr = "/文件夹名";
            string newRemoteFile = strFromName + "_《" + strTitleName + "》_" + strTypesName +"_"+ strFileNames; //传到服务器后的文件名称,比如log.txt        FtpConnection ftp = new FtpConnection();        try
            {
                string ftpIP ="xxx.xxx.8.75";//ConfigurationSettings.AppSettings["ftpIP"];
                string ftpUsrName = "xx"; //ConfigurationSettings.AppSettings["ftpUsrName"];
                string ftpUsrPsw = "xxx"; //ConfigurationSettings.AppSettings["ftpUsrPsw"];
                ftp.Connect(ftpIP, ftpUsrName, ftpUsrPsw);            if (ftp.DirectoryExist(remoteDr)) //检测ftp下是否存在该目录
                {
                    ftp.SetCurrentDirectory(remoteDr);
                }
                else
                {
                    ftp.CreateDirectory(remoteDr);
                    ftp.SetCurrentDirectory(remoteDr);
                }            ftp.PutFile(localFile, newRemoteFile);
                return strFtpError="1";//Ftp上传成功
            }
            catch (Exception err)
            {
                //throw err;
                return strFtpError = "2";//Ftp上传失败
            }
            finally
            {
                ftp.Close();
            }
        }