示例#1
0
    private void uploadToFtpButton_Click(object sender, EventArgs e)
    {
        uploadToSiteButton.Enabled = false;
        uploadToFtpButton.Enabled  = false;
        applyEffectButton.Enabled  = false;
        this.lifeTimer.Enabled     = false;
        try
        {
            if (mySettings.ftpOKsettings)
            {
                FTP f = new FTP(mySettings.ftphostSetting.ToString(), ".", mySettings.ftpusernameSetting, mySettings.ftppasswordSetting, mySettings.ftpportSetting);
                f.ChangeDirectory(mySettings.ftpdirectorySetting);
                f.UploadFile(_FileNameToHandle);
            }
            else
            {
                MessageBox.Show("Please supply ftp settings first");
            }

            //MessageBox.Show("Done");
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

        this.applyEffectButton.Enabled  = true;
        this.uploadToSiteButton.Enabled = true;
        this.uploadToFtpButton.Enabled  = true;
        this.lifeTimer.Enabled          = true;
    }
示例#2
0
        /*
         * public  bool UpdateFiles([Optional, DefaultParameterValue("")] string RemotePath)
         * {
         *
         *  if (RemotePath == "")
         *  {
         *      RemotePath = m_RemotePath;
         *  }
         *  else
         *  {
         *      m_RemotePath = RemotePath;
         *  }
         *  bool Ret = false;
         *  string AssemblyName = Assembly.GetEntryAssembly().GetName().Name;
         *  string ToDeleteExtension = ".ToDelete";
         *  string RemoteUri = RemotePath + AssemblyName + "/";
         *  WebClient MyWebClient = new  WebClient();
         *  try
         *  {
         *      for (string s = FileSystem.Dir(Application.StartupPath + @"\*" + ToDeleteExtension, FileAttribute.Normal); s != ""; s = FileSystem.Dir())
         *      {
         *          try
         *          {
         *              File.Delete(Application.StartupPath + @"\" + s);
         *          }
         *          catch (Exception exception1)
         *          {
         *              ProjectData.SetProjectError(exception1);
         *              Exception ex = exception1;
         *              ProjectData.ClearProjectError();
         *          }
         *      }
         *      string[] FileList = Strings.Split(Strings.Replace(MyWebClient.DownloadString(RemoteUri + UpdateFileName), "\n", "", 1, -1, CompareMethod.Binary), "\r", -1, CompareMethod.Binary);
         *      string Contents = "";
         *      foreach (string F in FileList)
         *      {
         *          if (Strings.InStr(F, "'", CompareMethod.Binary) != 0)
         *          {
         *              F = Strings.Left(F, Strings.InStr(F, "'", CompareMethod.Binary) - 1);
         *          }
         *          if (F.Trim() != "")
         *          {
         *              if (Contents != "")
         *              {
         *                  Contents = Contents + "\r";
         *              }
         *              Contents = Contents + F.Trim();
         *          }
         *      }
         *      FileList = Strings.Split(Contents, "\r", -1, CompareMethod.Binary);
         *      string[] Info = Strings.Split(FileList[0], ";", -1, CompareMethod.Binary);
         *      if (((((Application.StartupPath.ToLower() + @"\" + Info[0].ToLower()) == Application.ExecutablePath.ToLower()) && (Operators.CompareString(GetVersion(Info[1]), GetVersion(Application.ProductVersion), false) > 0)) ? 1 : 0) == 0)
         *      {
         *          return Ret;
         *      }
         *      foreach (string F in FileList)
         *      {
         *          Info = Strings.Split(F, ";", -1, CompareMethod.Binary);
         *          bool isToDelete = false;
         *          bool isToUpgrade = false;
         *          string TempFileName = Application.StartupPath + @"\" + Conversions.ToString(DateAndTime.Now.TimeOfDay.TotalMilliseconds);
         *          string FileName = Application.StartupPath + @"\" + Info[0].Trim();
         *          bool FileExists = File.Exists(FileName);
         *          if (Info.Length == 1)
         *          {
         *              isToUpgrade = true;
         *              isToDelete = FileExists;
         *          }
         *          else if (Info[1].Trim() == "delete")
         *          {
         *              isToDelete = FileExists;
         *          }
         *          else if (Info[1].Trim() == "?")
         *          {
         *              isToUpgrade = !FileExists;
         *          }
         *          else if (FileExists)
         *          {
         *              FileVersionInfo fv = FileVersionInfo.GetVersionInfo(FileName);
         *              isToUpgrade = Operators.CompareString(GetVersion(Info[1].Trim()), GetVersion(Conversions.ToString(fv.FileMajorPart) + "." + Conversions.ToString(fv.FileMinorPart) + "." + Conversions.ToString(fv.FileBuildPart) + "." + Conversions.ToString(fv.FilePrivatePart)), false) > 0;
         *              isToDelete = isToUpgrade;
         *          }
         *          else
         *          {
         *              isToUpgrade = true;
         *          }
         *          Debug.Print(TempFileName);
         *          if (isToUpgrade)
         *          {
         *              MyWebClient.DownloadFile(RemoteUri + Info[0], TempFileName);
         *          }
         *          if (isToDelete)
         *          {
         *              File.Move(FileName, TempFileName + ToDeleteExtension);
         *          }
         *          if (isToUpgrade)
         *          {
         *              File.Move(TempFileName, FileName);
         *          }
         *      }
         *      Process.Start(Application.ExecutablePath, Interaction.Command());
         *      Ret = true;
         *  }
         *  catch (Exception exception2)
         *  {
         *      ProjectData.SetProjectError(exception2);
         *      Exception ex = exception2;
         *      Ret = true;
         *      Interaction.MsgBox(m_ErrorMessage + "\r" + ex.Message + "\rAssembly: " + AssemblyName, MsgBoxStyle.Critical, Application.ProductName);
         *      ProjectData.ClearProjectError();
         *  }
         *  return Ret;
         * }
         */
        public void SendFile(String File)
        {
            frmProgress ofrm = new frmProgress();

            ofrm.Show();

            FTP.FTPPlumbing.Timeout     = 50000;
            FTP.FTPPlumbing.PassiveMode = true;

            FTP oFTP = new FTP();

            oFTP.Connect("192.168.254.65", "alvaro", "michelle"); //mail.giftcoinc.com

            oFTP.ChangeDirectory(".");
            oFTP.Files.Upload("File");
            while (!oFTP.Files.UploadComplete)
            {
                //MessageBox.Show("Uploading: TotalBytes: " + oFTP.Files.TotalBytes.ToString() + ", : PercentComplete: " + oFTP.Files.PercentComplete.ToString());
                ofrm.txtBar.Value = oFTP.Files.PercentComplete;
                ofrm.Update();
            }
            //MessageBox.Show("Upload Complete: TotalBytes: " + oFTP.Files.TotalBytes.ToString() + ", : PercentComplete: " + oFTP.Files.PercentComplete.ToString());
            ofrm.txtBar.Value = oFTP.Files.PercentComplete;
            ofrm.Update();


            oFTP.Disconnect();

            return;
        }
示例#3
0
        /// <summary>
        /// Retrieves a file from the FTP server
        /// </summary>
        /// <param name="URI"></param>
        /// <param name="DownloadDir"></param>
        /// <param name="FileName"></param>
        static public void DownloadFile(Uri URI, string DownloadDir, string FileName)
        {
            FTP Ftp = new FTP(URI.Host, URI.Port);

            Ftp.Connect(URI.UserInfo, "");
            Ftp.ChangeDirectory(URI.AbsolutePath);
            Ftp.GetFile(FileName, DownloadDir + "\\" + FileName, true);

            Ftp.Disconnect();
        }
示例#4
0
        private void ShowRLCServerFileViewer()
        {
            ListViewItem lvi;

            ListViewItem.ListViewSubItem lvsi;
            lstItems.Items.Clear();

            FTP clsFTP = new FTP();

            clsFTP.Connect(CONFIG.FTPIPAddress, CONFIG.FTPUsername, CONFIG.FTPPassword);
            if (CONFIG.FTPDirectory != null && CONFIG.FTPDirectory != string.Empty)
            {
                clsFTP.ChangeDirectory(CONFIG.FTPDirectory);
            }

            grpRLC.Text = "RLC File Server Management: [DOUBLE CLICK TO RELOAD] : " + CONFIG.FTPDirectory;

            try
            {
                foreach (FTP.File strFile in clsFTP.Files)
                {
                    if (strFile.ToString() != string.Empty)
                    {
                        lvi      = new ListViewItem();
                        lvi.Text = strFile.FileName;
                        //lvi.ImageIndex = 0;
                        lvi.Tag = strFile.ToString();

                        lvsi      = new ListViewItem.ListViewSubItem();
                        lvsi.Text = strFile.FileSize.ToString() + " kb";
                        lvi.SubItems.Add(lvsi);

                        lvsi      = new ListViewItem.ListViewSubItem();
                        lvsi.Text = strFile.FileDate.ToString("MM/dd/yyyy hh:mm tt");
                        lvi.SubItems.Add(lvsi);

                        lstItems.Items.Add(lvi);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error encountered while loading file list. " + Environment.NewLine + "Err #: " + ex.Message, "RetailPlus", MessageBoxButtons.OK);
            }

            clsFTP.Disconnect();
            clsFTP = null;
        }
示例#5
0
        /// <summary>
        /// Retrieves the listing of the files in current directory on FTP server
        /// </summary>
        /// <param name="URI"></param>
        /// <returns>The server file list as a List</returns>
        static public void ReadListing(Uri URI)
        {
            FTP Ftp = new FTP(URI.Host, URI.Port);

            ParamsHelper.AppsList = new List <string>();
            string Listing;

            Ftp.Connect(URI.UserInfo, "");

            try
            {
                Ftp.ChangeDirectory(URI.AbsolutePath);
                Listing = Ftp.GetFileList(false);
            }
            catch (Exception NewEx)
            {
                Listing = null;
                ParamsHelper.IsThreadAlive   = false;
                ParamsHelper.IsThreadError   = true;
                ParamsHelper.ThreadException = NewEx;
                return;
            }

            string[] Files = Listing.Replace("\n", "").Split('\r');

            foreach (string file in Files)
            {
                if (!String.IsNullOrEmpty(file) && file.IndexOf('.') == -1)
                {
                    ParamsHelper.AppsList.Add(file.Replace("_", " "));
                }
            }

            if (ParamsHelper.AppsList.Count == 0)
            {
                Ftp.Disconnect();
                ParamsHelper.IsThreadAlive   = false;
                ParamsHelper.IsThreadError   = true;
                ParamsHelper.ThreadException = new NetCFLibFTP.FTPException("Repository is empty");
                return;
            }

            Ftp.Disconnect();

            ParamsHelper.IsThreadAlive = false;
        }
示例#6
0
        public static void GetFile(String File)
        {
            FTP.FTPPlumbing.Timeout     = 50000;
            FTP.FTPPlumbing.PassiveMode = true;

            FTP oFTP = new FTP();

            oFTP.Connect("192.168.254.65", "alvaro", "michelle"); //mail.giftcoinc.com

            oFTP.ChangeDirectory(".");
            oFTP.Files.Download("File");
            while (!oFTP.Files.DownloadComplete)
            {
                MessageBox.Show("Uploading: TotalBytes: " + oFTP.Files.TotalBytes.ToString() + ", : PercentComplete: " + oFTP.Files.PercentComplete.ToString());
            }

            MessageBox.Show("Upload Complete: TotalBytes: " + oFTP.Files.TotalBytes.ToString() + ", : PercentComplete: " + oFTP.Files.PercentComplete.ToString());


            oFTP.Disconnect();

            return;
        }
示例#7
0
        private void ShowRLCServerFileViewer()
        {
            ListViewItem lvi;
            ListViewItem.ListViewSubItem lvsi;
            lstItems.Items.Clear();

            FTP clsFTP = new FTP();
            clsFTP.Connect(CONFIG.FTPIPAddress, CONFIG.FTPUsername, CONFIG.FTPPassword);
            if (CONFIG.FTPDirectory != null && CONFIG.FTPDirectory != string.Empty)
                clsFTP.ChangeDirectory(CONFIG.FTPDirectory);

            grpRLC.Text = "RLC File Server Management: [DOUBLE CLICK TO RELOAD] : " + CONFIG.FTPDirectory;

            try
            {
                foreach (FTP.File strFile in clsFTP.Files)
                {
                    if (strFile.ToString() != string.Empty)
                    {
                        lvi = new ListViewItem();
                        lvi.Text = strFile.FileName;
                        //lvi.ImageIndex = 0;
                        lvi.Tag = strFile.ToString();

                        lvsi = new ListViewItem.ListViewSubItem();
                        lvsi.Text = strFile.FileSize.ToString() + " kb";
                        lvi.SubItems.Add(lvsi);

                        lvsi = new ListViewItem.ListViewSubItem();
                        lvsi.Text = strFile.FileDate.ToString("MM/dd/yyyy hh:mm tt");
                        lvi.SubItems.Add(lvsi);

                        lstItems.Items.Add(lvi);
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Error encountered while loading file list. " + Environment.NewLine + "Err #: " + ex.Message, "RetailPlus", MessageBoxButtons.OK);
            }

            clsFTP.Disconnect();
            clsFTP = null;
        }
示例#8
0
文件: main.cs 项目: vantruc/skimpt
 /// <summary>
 /// This function tests the FTP connection if valid values are given
 /// </summary>
 private void ftpTestConnButton_Click(object sender, EventArgs e)
 {
     try
     {
         FTP f = new FTP(mySettings.ftphostSetting.ToString(), ".", mySettings.ftpusernameSetting, mySettings.ftppasswordSetting, mySettings.ftpportSetting);
         f.ChangeDirectory(mySettings.ftpdirectorySetting);
         mySettings.ftpOKsettings = true;
         mySettings.Save();
         utilities.ShowMessage("Test Successfull", "FTP Test");
     }
     catch(Exception ex)
     {
         mySettings.ftpOKsettings = false;
         mySettings.Save();
         utilities.ShowMessage(ex.Message + Environment.NewLine + "Test Failed", "Failed");
     }
 }
示例#9
0
        /// <summary>
        /// Retrieves a package information from the FTP server
        /// </summary>
        /// <param name="URI"></param>
        /// <param name="AppName"></param>
        /// <returns>The file info as a string</returns>
        static public string LoadInfo(Uri URI, string AppName)
        {
            FTP    Ftp         = new FTP(URI.Host, URI.Port);
            string FileName    = AppName + ".zip";
            string InfoName    = AppName + ".info";
            string ScrShotName = AppName + ".png";
            string LogoName    = "Logo.png";
            string FileSize;
            string BufferPath = ParamsHelper.TempPath + "\\" + AppName;
            string AppInfo;

            if (!Directory.Exists(BufferPath))
            {
                Directory.CreateDirectory(BufferPath);
            }

            Ftp.Connect(URI.UserInfo, "");

            try
            {
                Ftp.ChangeDirectory(URI.AbsolutePath);
                FileSize = Ftp.GetFileSize(FileName);
                FileSize = ParamsHelper.BytesToMegs((ulong)Convert.ToInt64(FileSize)).ToString("0.###") + " МБ";
            }
            catch
            {
                FileSize = null;
            }

            try
            {
                Ftp.GetFile(InfoName, BufferPath + "\\" + InfoName, true);
                InfoName = BufferPath + "\\" + InfoName;
            }
            catch
            {
                File.Delete(BufferPath + "\\" + InfoName);
                InfoName = null;
            }

            try
            {
                Ftp.GetFile(LogoName, BufferPath + "\\" + LogoName, true);
                LogoName = BufferPath + "\\" + LogoName;
            }
            catch
            {
                File.Delete(BufferPath + "\\" + LogoName);
                LogoName = null;
            }

            try
            {
                Ftp.GetFile(ScrShotName, BufferPath + "\\" + ScrShotName, true);
                ScrShotName = BufferPath + "\\" + ScrShotName;
            }
            catch
            {
                File.Delete(BufferPath + "\\" + ScrShotName);
                ScrShotName = null;
            }

            AppInfo = FileSize + "\n" + InfoName + "\n" + LogoName + "\n" + ScrShotName;

            Ftp.Disconnect();

            return(AppInfo);
        }
示例#10
0
    private void uploadToFtpButton_Click(object sender, EventArgs e)
    {
        uploadToSiteButton.Enabled = false;
        uploadToFtpButton.Enabled = false;
        applyEffectButton.Enabled = false;
        this.lifeTimer.Enabled = false;
        try
        {
            if(mySettings.ftpOKsettings)
            {
                FTP f = new FTP(mySettings.ftphostSetting.ToString(), ".", mySettings.ftpusernameSetting, mySettings.ftppasswordSetting, mySettings.ftpportSetting);
                f.ChangeDirectory(mySettings.ftpdirectorySetting);
                f.UploadFile(_FileNameToHandle);
            }
            else
            {
                MessageBox.Show("Please supply ftp settings first");
            }

            //MessageBox.Show("Done");
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

        this.applyEffectButton.Enabled = true;
        this.uploadToSiteButton.Enabled = true;
        this.uploadToFtpButton.Enabled = true;
        this.lifeTimer.Enabled = true;
    }