Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I am using vb.net2003 working on multiple websites that is on diffrent
server on FTP. and I want to be upload a files from local machine to on FTP.
for that i am using master control page that is in one website(1) and FTP server(1) for all website users and that is located on FTPserver(1) on FTP.
and Now I want to connect that control panel from other websites
i.e, website(2) that is located on FTPserver(2) and I want to upload files to FTP.

server.mappath() is searching on ftpserver(1) but I want to upload file on ftpserver(2).

please help me.
if u can.
ASAP.

Thanks
ur co-operaion.
Posted

I suggest looking for code in perl and call the perl module for your application.
 
Share this answer
 
downloadDownload the source code -423 KB




Introduction:

Today I put a sample program to manage your FTP
Perhaps all of you with many programs to work with FTP or have seen much of you need to have transferred the file to the server or servers to receive and manage the server.
It can create folders, manage and delete files and folders, upload and download files to your will.


Familiar with the concept for "FTP" and the launch method, click here




To view original size Click on the photos.

Software_FTP
View_FTP


Background:
The software language is written in C # 2008.
I plan to have written part of office automation and felt that's too difficult to copy and upload in a network environment are fully software compatible with Windows Server - XP and 7 are by all FTP Microsoft and all FTP installed on the data center support.



Comment code:
1 - Uploading a file:



 private void Btn_UploadFTP_Click(object sender, EventArgs e)
{
   string _tempServerPath = Txt_ServerPath.Text + <br />           "\\" + Path.GetFileName(Txt_LocalPath_Upload.Text);
   ftPclient1.FTPclient_SetInfo(Txt_Domain.Text, Txt_User.Text, Txt_Pass.Text);
   ftPclient1.Upload(Txt_LocalPath_Upload.Text, _tempServerPath);
}
public bool Upload(FileInfo fi, [Optional, DefaultParameterValue("")] string targetFilename)
{
  string str;
  bool _Lvr=true;
  if (targetFilename.Trim() == "")
     {
       str = this.CurrentDirectory + fi.Name;
     }
  else if (targetFilename.Contains("/"))
     {
       str = this.AdjustDir(targetFilename);
     }
   else
      {
        str = this.CurrentDirectory + targetFilename;
      }
   string uRI = this.Hostname + str;
   FtpWebRequest request = this.GetRequest(uRI);
   request.Method = "STOR";
   request.UseBinary = true;
   request.ContentLength = fi.Length;
   byte[] array = new byte[0x800];
   using (FileStream stream = fi.OpenRead())
      {
       try
         {
          using (Stream stream2 = request.GetRequestStream())
            {
             int num;
               do
                {
                  num = stream.Read(array, 0, 0x800);
                  stream2.Write(array, 0, num);
                  Application.DoEvents();<br />                  CountProcesses = <br />                             Convert.ToInt32(<br />                             Math.Round((decimal)(stream.Position * 100) / stream.Length));
                  ChangePerocesses_Upload();
                 }
                while (num >= 0x800);
               stream2.Close();
              }
           }
           catch (Exception exception1)
            {
             _Lvr = false;
              ProjectData.SetProjectError(exception1);
              Exception exception = exception1;
              ProjectData.ClearProjectError();
             }
            finally
             {
               stream.Close();
             }
        }
   request = null;
   UploadComplite();
   return _Lvr;
}


2 - Download the file:

private void button4_Click(object sender, EventArgs e)
{
   string _Source_DownloadPath = Txt_ServerPath.Text + "\\" + Txt_FileNameDownload.Text;
   ftPclient1.FTPclient_SetInfo(Txt_Domain.Text, Txt_User.Text, Txt_Pass.Text);
   ftPclient1.Download(_Source_DownloadPath, Txt_LocalPath_Download.Text, false);
}





3 - Display files:

private void button5_Click(object sender, EventArgs e)
{
    Txt_View_FtpFile.Text = string.Empty; ;
    ftPclient1.FTPclient_SetInfo(Txt_Domain.Text, Txt_User.Text, Txt_Pass.Text);
    List<string> _listFile = ftPclient1.ListDirectory("//"+Txt_ServerPath.Text);
    for (int i = 0; i < _listFile.Count; i++)
     {
       Txt_View_FtpFile.Text += _listFile[i].ToString() + Environment.NewLine;
     }
}


 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900