public static void CreateDirectoryEx(this FTPConnection connection, string directory) { // have to create each individual directory in the requested tree var dirFragment = directory; var dirTree = new List <string>(); while (!string.IsNullOrEmpty(dirFragment)) { var dir = Path.GetFileName(dirFragment); dirTree.Insert(0, dir); dirFragment = Path.GetDirectoryName(dirFragment); } for (var i = 0; i < dirTree.Count; i++) { var newDir = dirTree[i]; var bRet = false; try { bRet = connection.ChangeWorkingDirectory(newDir); } catch (FTPException) { } if (!bRet) { connection.CreateDirectory(newDir); connection.ChangeWorkingDirectory(newDir); } Debug.WriteLine(connection.ServerDirectory); } }
/// <summary> /// 如果目录不存在,创建目录 /// </summary> /// <param name="dirName"></param> /// <param name="connection"></param> private void MakeSureDirExist(string dirName, FTPConnection connection) { if (!connection.DirectoryExists(dirName)) { connection.CreateDirectory(dirName); } }
public Boolean DeletePack(int v) { // 输出递交包,到本地集成环境处理,需要使用ftp连接 FTPConnection ftp = MAConf.instance.Configs[ProductId].ftp; FtpConf fc = MAConf.instance.Configs[ProductId].fc; // 强制重新连接,防止时间长了就断掉了 if (ftp.IsConnected == false) { try { ftp.Connect(); } catch (Exception e) { log.WriteErrorLog("连接FTP服务器失败,错误信息:" + e.Message); } } if (ftp.DirectoryExists(RemoteDir) == false) { System.Windows.Forms.MessageBox.Show("FTP路径" + RemoteDir + "不存在!"); return(false); } //ftp.ChangeWorkingDirectory(fc.ServerDir); ftp.DeleteFile(RemoteFile); return(true); }
public static void Check(ref FTPConnection ftpcon) { try { // return if disabled if ((Config.settings.MinecraftVersion == "") || (Config.settings.MinecraftDownloadFile == "")) { return; } // ok when launcher is there if (File.Exists(Locations.Launcher_Install) || File.Exists(Locations.Launcher_Download)) { Console.WriteLine(Strings.Get("MinecraftOK")); return; } // download launcher if (!Directory.Exists(Locations.LocalFolderName_Launcher)) { Directory.CreateDirectory(Locations.LocalFolderName_Launcher); } Console.WriteLine(Strings.Get("MinecraftDownload")); ftpcon.DownloadFile(Locations.Launcher_Download, Config.ftpsettings.FtpServerFolder + "/" + Config.settings.MinecraftDownloadFile); } catch (Exception ex) { Console.WriteLine(Strings.Get("MinecraftError") + ex.Message); Console.WriteLine(Strings.Get("PressKey")); Console.ReadKey(); Program.Exit(false); } }
/// <summary> /// Ova funcija šalje podatke i bazu na ftp server. /// </summary> /// <param name="server">Referenca na objekat FTPConnection.</param> /// <param name="lstAdresa">Lista adresa fajlova koji treba da se pošalju.</param> public static bool slanjeFajlova_i_BazeNaServer(FTPConnection server, List <String> lstAdresa) { try { if (slanjeFajlovaNaServer(server, lstAdresa)) { if (slanjeFajlaNaServer(server, Application.StartupPath + @"\Baza.s3db")) { return(true); } else { return(false); } } else { return(false); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Greška"); return(false); } }
//hack[Test] public void FTPS() { try { var settings = new FTPConnection.SettingsData { RemoteHost = "192.168.0.150", RemotePort = 21, UserName = "******", Password = "******", UseSSL = false }; using (var ftp = new FTPConnection()) { ftp.TraceMessage += (s, a) => { System.Diagnostics.Debug.Write(string.Format(s, a)); }; ftp.Login(settings); ftp.AsciiMode = true; ftp.Upload(@"D:\deleteme\test.html"); ftp.Close(); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Caught Error :" + e.Message); } }
/// <summary> /// 连接FTP服务器 /// </summary> /// <param name="ftpInfo"></param> /// <returns></returns> public static bool ConnectFtpServer(FtpConfigEntity ftpInfo) { try { using (FTPConnection ftpConn = new FTPConnection { ServerAddress = ftpInfo.ServerAddress, //ServerDirectory = ftpInfo.ServerDirectory, UserName = ftpInfo.UserName, Password = ftpInfo.UserPassword, CommandEncoding = Encoding.GetEncoding("GBK") }) { ftpConn.Connect(); if (!ftpConn.DirectoryExists(ftpInfo.ServerDirectory)) { throw new Exception($"FTP服务器连接成功,但FTP服务器不存在目录名[{ftpInfo.ServerDirectory}]"); } } return(true); } catch (Exception ex) { string errMsg = $"FTP服务器连接失败,FTP信息[{JsonObj<FtpConfigEntity>.ToJson(ftpInfo)}],异常[{ ex.Message}]"; LogUtil.WriteLog(errMsg); throw new Exception(errMsg); } }
/// <summary> /// 执行一个ftp操作 /// </summary> /// <param name="action"></param> /// <param name="exceptionHandler"></param> public void SafeAction(Action <FTPConnection> action, Action <Exception> exceptionHandler = null) { try { using (FTPConnection connection = new FTPConnection()) { connection.ServerAddress = _serverIp; connection.UserName = _userName; connection.Password = _password; connection.ServerPort = _serverPort; //默认使用的就是PASV被动模式 connection.ConnectMode = FTPConnectMode.PASV; //设置传输类型Binary,默认就是Binary connection.TransferType = FTPTransferType.BINARY; //不用设置命令编码,采用默认值,注意传输文件名使用ASCII值 //只使用0-127的文件名不会出错。 connection.Timeout = 6000;//单位毫秒 connection.Connect(); if (action != null) { action(connection); } } } catch (Exception ex) { if (exceptionHandler != null) { exceptionHandler(ex); } } }
private static void DeleteDirectoryRecursively(FTPConnection ftpConnect, string remotePath) { ftpConnect.ChangeWorkingDirectory(remotePath); var files = ftpConnect.GetFileInfos().Where(x => !x.Name.Contains(".") || x.Name.Contains("jpg")); foreach (var tmp in files) { if (!tmp.Dir) { ftpConnect.DeleteFile(tmp.Name); } } // delete all subdirectories in the remotePath directory foreach (var tmp in files) { if (tmp.Dir) { DeleteDirectoryRecursively(ftpConnect, tmp.Name); } } // delete this directory ftpConnect.ChangeWorkingDirectoryUp(); ftpConnect.DeleteDirectory(remotePath); }
// downloads modsync.xml public static void FtpUpdate(ref FTPConnection ftpcon) { string ConfigFile = "modsync.xml"; string LocalFile = Locations.LocalFolderName_Minecraft + "\\" + ConfigFile; string RemoteFile = ftpsettings.FtpServerFolder + "/" + ConfigFile; try { if (ftpcon.Exists(RemoteFile)) { ftpcon.DownloadFile(LocalFile, RemoteFile); settings = (Settings)Read(typeof(Settings), LocalFile); } else { Console.WriteLine(Strings.Get("ConfigMissing")); } } catch (Exception ex) { Console.WriteLine(Strings.Get("ConfigError") + ex.Message); Console.WriteLine(Strings.Get("PressKey")); Console.ReadKey(); } }
public void UpdateAttachments(List<Attachment> filesToSave, List<string> localPathToSave, Procedure procedure) { if (filesToSave.Count > 0) { MedicalRecord medicalRecord = (from m in appManager.ApplicationDb.MedicalRecords from p in m.Procedures where p.Id == procedure.Id select m).FirstOrDefault(); Patient patient = (from p in appManager.ApplicationDb.Patients from m in p.MedicalHistory where m.Id == medicalRecord.Id select p).FirstOrDefault(); FTPConnection ftp = new FTPConnection("193.224.69.39", "balu", "szoftech", "hubasky/attachments"); string medicalRecordPath = String.Format("{0}/{1}", patient.Ssn, medicalRecord.Id); string ftpFileName = ""; try { ftp.CreateDirectory(medicalRecordPath); } catch (WebException) { //MessageBox.Show(e.Status.ToString() + ": Már létezik a könytár!"); } for (int i = 0; i < filesToSave.Count(); i++) { ftpFileName = String.Format("{0}/{1}_{2}_{3}", medicalRecordPath, procedure.Id, filesToSave[i].Id, filesToSave[i].File); ftp.UploadFile(ftpFileName, localPathToSave[i]); } } }
private void bt_teste_Click(object sender, EventArgs e) { if (tb_ftp.SelectedTab == tb_ftp.TabPages["tb_page_empresa"]) { if (tb_tab_empresa_address.Text.Equals("") || tb_tab_empresa_user.Text.Equals("") || tb_tab_empresa_pass.Text.Equals("")) { MessageBox.Show("Preencha todos os campos!", "Atenção"); tb_tab_empresa_address.Focus(); } else { FTPConnection ftp = new FTPConnection(); if (ftp.TestConnection(tb_tab_empresa_address.Text, tb_tab_empresa_user.Text, tb_tab_empresa_pass.Text)) { bt_save.Enabled = true; } } } else { if (tb_tab_server_address.Text.Equals("") || tb_tab_server_user.Text.Equals("") || tb_tab_server_pass.Text.Equals("")) { MessageBox.Show("Preencha todos os campos!", "Atenção"); tb_tab_server_address.Focus(); } else { FTPConnection ftp = new FTPConnection(); if (ftp.TestConnection(tb_tab_server_address.Text, tb_tab_server_user.Text, tb_tab_server_pass.Text)) { bt_save.Enabled = true; } } } }
public Controller() { userRepo = new UserRepository(new UserSQLContext()); mediaRepo = new MediaRepository(new MediaSQLContext()); reservationRepo = new ReservationRepository(new ReservationSQLContext()); ftp = new FTPConnection(); Event = new Event("SocialEvent"); }
public FtpLib(ref FTPConnection con) { this.FtpServer = con; this.FtpServer.ReplyReceived += HandleMessages; this.FtpServer.CommandSent += HandleMessages; this.FtpServer.Downloaded += new FTPFileTransferEventHandler(FtpServer_Downloaded); this.FtpServer.Uploaded += new FTPFileTransferEventHandler(FtpServer_Uploaded); this.FtpServer.BytesTransferred += HandleProgress; //this.FtpServer.TransferNotifyInterval = 1024; }
public void RunTestOutsideHarness(bool useAbsPaths) { Init(); ftp = new FTPConnection(); ftp.ServerAddress = "localhost"; ftp.UserName = "******"; ftp.Password = "******"; PrepareConnection(); ftp.Connect(); RunTests(useAbsPaths); }
// updates single executable public static void ExecutableUpdate(ref FTPConnection ftpcon) { // return if clickonce deployed if (ApplicationDeployment.IsNetworkDeployed) { return; } // return if disabled if (Config.settings.ToolVersion == "") { return; } // get location and version Assembly file = Assembly.GetExecutingAssembly(); string file_location = file.Location; string file_version = FileVersionInfo.GetVersionInfo(file_location).FileVersion; int curversion, newversion; if (int.TryParse(file_version.Replace(".", ""), out curversion) && int.TryParse(Config.settings.ToolVersion.Replace(".", ""), out newversion)) { // update if newer available if (curversion < newversion) { string LocalFile = Locations.LocalFolderName_Minecraft + "\\" + Config.settings.ToolDownloadFile; string RemoteFile = Config.ftpsettings.FtpServerFolder + "/" + Config.settings.ToolDownloadFile; try { // download new file Console.WriteLine(Strings.Get("AutoUpdate")); ftpcon.DownloadFile(LocalFile, RemoteFile); // start a process with a delayed file copy Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.WindowStyle = ProcessWindowStyle.Normal; startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/C ping 127.0.0.1 -n 1 -w 5000 > nul & copy /Y " + LocalFile + " " + file_location + " & " + file_location; process.StartInfo = startInfo; process.Start(); Program.Exit(false); } catch (Exception ex) { Console.WriteLine(Strings.Get("AutoUpdateError") + " " + ex.Message); Console.ReadKey(); } } } }
/// <summary> /// Ova funkcija šalje jedan fajl na ftp server. /// </summary> /// <param name="server">Referenca na objekat FTPConnection.</param> /// <param name="putanjaFajla">Localna putanja do fajla.</param> public static bool slanjeFajlaNaServer(FTPConnection server, string putanjaFajla) { try { server.UploadFile(putanjaFajla, putanjaFajla.Substring(pointerString(putanjaFajla) + 2)); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Greška"); return(false); } }
/// <summary> /// 上传文件 /// </summary> /// <param name="ftpInfo"></param> /// <param name="sourceFilepath"></param> public static void UploadFile(FtpConfigEntity ftpInfo, string sourceFilepath) { if (ftpInfo == null) { throw new Exception("FtpHelper.UploadFile()方法,参数ftpInfo为空"); } if (string.IsNullOrEmpty(sourceFilepath)) { throw new Exception("FtpHelper.UploadFile()方法,参数sourceFilepath为空"); } if (!File.Exists(sourceFilepath)) { throw new Exception($"FtpHelper.UploadFile()方法,参数sourceFilepath[{sourceFilepath}]指定文件路径不存在"); } try { using (FTPConnection ftpConn = new FTPConnection { ServerAddress = ftpInfo.ServerAddress, ServerDirectory = ftpInfo.ServerDirectory, UserName = ftpInfo.UserName, Password = ftpInfo.UserPassword, CommandEncoding = Encoding.GetEncoding("GB2312") }) { ftpConn.Connect(); string tempFtpFileName = FileHelper.GetFileName(sourceFilepath) + ".part"; string ftpFileName = FileHelper.GetFileName(sourceFilepath); bool exist_file = ftpConn.Exists(tempFtpFileName); if (exist_file) { LogUtil.WriteLog($"FTP服务器存在同名文件[{tempFtpFileName}],将ResumeNextTransfer"); ftpConn.ResumeNextTransfer(); } ftpConn.UploadFile(sourceFilepath, tempFtpFileName, exist_file); Thread.Sleep(200); ftpConn.RenameFile(tempFtpFileName, ftpFileName); } } catch (Exception ex) { throw new Exception($"数据文件[{sourceFilepath}]上传失败,异常信息[{ex.Message}][{ex.StackTrace}]"); } }
[TestMethod]//功能强 public void MyFtpTest1() { var ftp = new FTPConnection(); ftp.ServerAddress = "115.159.186.113"; ftp.ServerPort = 21; ftp.UserName = "******"; ftp.Password = "******"; ftp.CommandEncoding = Encoding.GetEncoding("GBK");//设置编码 //连接 ftp.Connect(); ftp.ConnectMode = FTPConnectMode.PASV; ftp.TransferType = FTPTransferType.BINARY; string[] files = ftp.GetFiles(); FTPFile[] fileDetails = ftp.GetFileInfos(); ////当前目录 string directory = ftp.WorkingDirectory; ////切换目录 进入指定的目录 bool change = ftp.ChangeWorkingDirectory("/tools/测试证书pfx/"); files = ftp.GetFiles(); fileDetails = ftp.GetFileInfos(); ////切换到上级目录 //bool b = ftp.ChangeWorkingDirectoryUp(); ////上传文件 //ftp.UploadFile(localFilePath, remoteFileName); ////上传文件 已存是否覆盖 //ftp.UploadFile(localFilePath, remoteFileName, true); ////下载文件 //ftp.DownloadFile("b2bic-副本.rar", "/tools/b2bic-副本.rar"); //将内存字节数据上传到远程服务器 //ftp.UploadByteArray(bytes, remotFileName); //下载远程文件到本地内存 //byte[] bytes = ftp.DownloadByteArray(remoteFileName); //删除远程文件 //bool dFlag = ftp.DeleteFile(remoteFileName); //内存流上传到远程服务器 //ftp.UploadStream(stream, remoteFileName); //关闭 ftp.Close(); }
/// <summary> Connect to the server </summary> internal void Connect(int timeout, bool autoLogin) { // connect ftp = new FTPConnection(); ftp.AutoLogin = autoLogin; ftp.ServerAddress = host; ftp.ServerPort = FTPControlSocket.CONTROL_PORT; ftp.Timeout = timeout; ftp.ConnectMode = connectMode; ftp.UserName = user; ftp.Password = password; log.Debug("Connecting to " + host); ftp.Connect(); log.Debug("Connected to " + host); }
private void Connect() { if (connection != null && connection.IsConnected) { return; } connection = new FTPConnection(); connection.Timeout = Timeout; connection.ServerAddress = account.Url; connection.UserName = account.UserName; connection.Password = account.Password; connection.Connect(); }
static void Install(ref FTPConnection ftpcon) { // create default profile if missing if (!File.Exists(Locations.LauncherProfiles)) { UpdateProfile("(Default)", Config.settings.MinecraftVersion); } string LocalFile = Locations.LocalFolderName_TempDir + "\\" + Config.settings.ForgeDownloadFile; string RemoteFile = Config.ftpsettings.FtpServerFolder + "/" + Config.settings.ForgeDownloadFile; try { // download and install forge Console.WriteLine(Strings.Get("ForgeDownload")); File.Delete(LocalFile); ftpcon.DownloadFile(LocalFile, RemoteFile); Console.WriteLine(Strings.Get("ForgeInstall")); if (File.Exists(Locations.Java)) { // extract wrapper class to invoke client install Resources.ExtractFile(Locations.LocalFolderName_TempDir, "ForgeInstallWrapper.class"); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = Locations.Java; psi.WorkingDirectory = Path.GetDirectoryName(LocalFile); psi.Arguments = "-cp \"" + Locations.LocalFolderName_TempDir + "\" ForgeInstallWrapper \"" + Config.settings.ForgeDownloadFile + "\" \"" + Locations.LocalFolderName_Minecraft + "\""; psi.UseShellExecute = false; var process = Process.Start(psi); process.WaitForExit(); File.Delete(LocalFile); File.Delete(Locations.LocalFolderName_TempDir + "\\" + "ForgeInstallWrapper.class"); } else { Process.Start(LocalFile); // exit without starting game Program.Exit(false); } } catch (Exception ex) { Console.WriteLine(Strings.Get("ForgeError") + ex.Message); Console.WriteLine(Strings.Get("PressKey")); Console.ReadKey(); Program.Exit(true); } }
static void Main(string[] args) { using (var connection = new FTPConnection { ServerAddress = "127.0.0.1", UserName = "******", Password = "******", }) { connection.Connect(); connection.ServerDirectory = "/recursive_folder"; var resultRecursive = connection.GetFileInfosRecursive().Where(f => !(f.Name.EndsWith(".old"))).ToList(); var resultDefault = connection.GetFileInfos().Where(f => !(f.Name.EndsWith(".old"))).ToList(); } }
public static FTPFile[] GetFileInfosRecursive(this FTPConnection connection) { var resultList = new List <FTPFile>(); var fileInfos = connection.GetFileInfos(); resultList.AddRange(fileInfos); foreach (var fileInfo in fileInfos) { if (fileInfo.Dir) { connection.ServerDirectory = fileInfo.Path; resultList.AddRange(connection.GetFileInfosRecursive()); } } return(resultList.ToArray()); }
public static void Check(ref FTPConnection ftpcon) { // return if disabled if ((Config.settings.JavaVersion == "") || (Config.settings.JavaDownloadFile == "")) { return; } // check registery key RegistryKey subKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\JavaSoft\\Java Runtime Environment\\" + Config.settings.JavaVersion); if (subKey != null) { Locations.Javaw = subKey.GetValue("JavaHome").ToString() + "\\bin\\javaw.exe"; Locations.Java = subKey.GetValue("JavaHome").ToString() + "\\bin\\java.exe"; Console.WriteLine(Strings.Get("JavaOK")); return; } Console.WriteLine(Strings.Get("JavaNotFound") + Config.settings.JavaVersion); string LocalFile = Locations.LocalFolderName_TempDir + "\\" + Config.settings.JavaDownloadFile; string RemoteFile = Config.ftpsettings.FtpServerFolder + "/" + Config.settings.JavaDownloadFile; try { // download and install java Console.WriteLine(Strings.Get("JavaDownload")); File.Delete(LocalFile); ftpcon.DownloadFile(LocalFile, RemoteFile); Console.WriteLine(Strings.Get("JavaInstall")); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = LocalFile; psi.WorkingDirectory = Path.GetDirectoryName(LocalFile); psi.Verb = "runas"; psi.Arguments = "/s"; psi.UseShellExecute = true; var process = Process.Start(psi); process.WaitForExit(); File.Delete(LocalFile); } catch (Exception ex) { Console.WriteLine(Strings.Get("JavaError") + ex.Message); Console.WriteLine(Strings.Get("PressKey")); Console.ReadKey(); } }
/// <summary> /// Ova funcija šalje podatke na ftp server. /// </summary> /// <param name="server">Referenca na objekat FTPConnection.</param> /// <param name="lstAdresa">Lista adresa fajlova koji treba da se pošalju.</param> public static bool slanjeFajlovaNaServer(FTPConnection server, List <String> lstAdresa) { try { for (int i = 0; i < lstAdresa.Count; i++) { server.UploadFile(lstAdresa[i], lstAdresa[i].Substring(pointerString(lstAdresa[i]) + 2)); } return(true); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Greška"); return(false); } }
static bool FtpOpen() { // create connection try { ftpcon = new FTPConnection(); ftpcon.UserName = Config.ftpsettings.FtpUserName; ftpcon.Password = Config.ftpsettings.FtpPassword; ftpcon.ServerAddress = Config.ftpsettings.FtpServerAddress; ftpcon.ServerPort = int.Parse(Config.ftpsettings.FtpServerPort); ftpcon.TransferNotifyInterval = (long)4096; ftp = new FtpLib(ref ftpcon); } catch (Exception) { Console.WriteLine(Strings.Get("FtpBadConfig")); Console.ReadKey(); return(false); } // try to connect try { ftp.LogIn(); } catch (Exception) { Console.WriteLine(Strings.Get("FtpNoConnection")); Console.ReadKey(); return(false); } // check if folder exists if (!Config.ftpsettings.FtpServerFolder.StartsWith("/")) { Config.ftpsettings.FtpServerFolder = "/" + Config.ftpsettings.FtpServerFolder; } if (!ftpcon.DirectoryExists(Config.ftpsettings.FtpServerFolder)) { Console.WriteLine(Strings.Get("FtpBadFolder") + Config.ftpsettings.FtpServerFolder); Console.ReadKey(); return(false); } return(true); }
/// <summary> /// /// </summary> /// <param name="ip"></param> public void testServer(string ip) { FTPConnection ftp = new FTPConnection(); string current = "setup"; try { Console.Out.WriteLine("Testing: " + ip); ftp.ServerAddress = ip; ftp.UserName = "******"; ftp.Password = "******"; ftp.Timeout = 5000; current = "connecting"; ftp.Connect(); current = "uploading"; ftp.UploadFile("test.txt", "test.txt"); current = "testing"; if (ftp.Exists("test.txt")) { current = "deleting"; ftp.DeleteFile("test.txt"); Console.WriteLine("OK: " + ip, Color.Lime); okservers++; goodServers.Add(ip); using (StreamWriter w = File.AppendText(outputFile)) { w.WriteLine(ip); } } else { throw new Exception("File could not be uploaded" + ip); } ftp.DeleteFile("test.txt"); } catch (Exception ex) { Console.WriteLine("Error: " + current + " " + ex.Message); } finally { current = "closing"; ftp.Close(); } }
/// <summary> /// File via FTP öffnen /// </summary> /// <returns></returns> private void logViaFTPÖffnenToolStripMenuItem_Click(object sender, EventArgs e) { TextBox.Clear(); IniFile lIni = new IniFile(); if (lIni.Read("LOG", "Receiver") == "") { return; } string ftpUri = lIni.Read("IP", "Receiver"); string ftpUser = lIni.Read("USER", "Receiver");; string passwd = lIni.Read("PWD", "Receiver"); string ftpfileName = Path.GetFileName(lIni.Read("LOG", "Receiver")); string ftpfilePath = lIni.Read("LOG", "Receiver"); ftpfilePath = ftpfilePath.Remove(Math.Max(0, ftpfilePath.Length - ftpfileName.Length - 1), ftpfileName.Length + 1); FTPConnection ftpCon = new FTPConnection(); string localFileName = Path.GetTempFileName(); //Prgressbar aufbauen ProgressForm lProgress = new ProgressForm(); lProgress.StartPosition = FormStartPosition.CenterParent; lProgress.Show(this); lProgress.SetProgress("Öffne FTP Verbindung", 0); //FTP verbinden ftpCon.Open(ftpUri, ftpUser, passwd, FTPMode.Passive); lProgress.SetProgress("Wechsle Verzeichnis", 20); ftpCon.SetCurrentDirectory(ftpfilePath); lProgress.SetProgress("Lade Daten", 40); ftpCon.GetFile(ftpfileName, localFileName, FTPFileTransferType.Binary); lProgress.SetProgress("Schließe Verbindung", 60); ftpCon.Close(); lProgress.SetProgress("Lese Datei", 80); readFile(localFileName); //Ende lProgress.SetProgress("Fertig ...", 100); lProgress.Close(); CountLines(); DetectCamType(); ReadLengthInfo(vCamType); }
public static void Check(ref FTPConnection ftpcon) { // return if disabled if ((Config.settings.ForgeVersion == "") || (Config.settings.ForgeDownloadFile == "")) { return; } // check forge json file if (File.Exists(Locations.LocalFolderName_Versions + "\\" + Config.settings.ForgeVersion + "\\" + Config.settings.ForgeVersion + ".json")) { Console.WriteLine(Strings.Get("ForgeOK")); } else { Install(ref ftpcon); } UpdateProfile("Forge", Config.settings.ForgeVersion); }