Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why Export Definition files are used in FTP servers
Posted

I don't think you observation is correct. What makes you thinking they are "used"?

—SA
 
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