Dateien können jetzt über FTP heruntergeladen werden
This commit is contained in:
@@ -11,6 +11,7 @@ using KlassenBIB;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using SanShared;
|
||||
using FluentFTP;
|
||||
|
||||
namespace SanSystem
|
||||
{
|
||||
@@ -24,6 +25,7 @@ namespace SanSystem
|
||||
}
|
||||
InlinerSanierung inliner = null;
|
||||
string destinationPath = string.Empty;
|
||||
List<string> filenames = new List<string>();
|
||||
public UCInliner(InlinerSanierung san)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -101,7 +103,7 @@ namespace SanSystem
|
||||
|
||||
private void CheckDirectories()
|
||||
{
|
||||
destinationPath = inliner.CheckVerzeichnisse(Global.Instance.projektpfad);
|
||||
destinationPath = inliner.CheckVerzeichnisse(Global.Instance.Projektpfad);
|
||||
}
|
||||
|
||||
private void btn_get_temp_Click(object sender, EventArgs e)
|
||||
@@ -114,5 +116,67 @@ namespace SanSystem
|
||||
|
||||
txt_temp_aussen.Update();
|
||||
}
|
||||
|
||||
private void btn_transfer_ftp_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Progress<double> progress = new Progress<double>(x =>
|
||||
{
|
||||
if(x < 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpProgress.Value = Convert.ToInt32(x);
|
||||
}
|
||||
});
|
||||
filenames.Clear();
|
||||
if (MessageBox.Show("Bitte stellen Sie sicher, dass der Server antwortet und dass nur die Dateien vorhanden sind!", "WARNUNG", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop) == DialogResult.OK)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
FtpClient client = new FtpClient("192.168.1.2");
|
||||
client.Credentials = new System.Net.NetworkCredential("damian", "bodde05");
|
||||
client.Connect();
|
||||
//client.ListingParser = FtpParser.UnixAlt;
|
||||
|
||||
ListFiles(client, "/");
|
||||
|
||||
foreach (string file in filenames)
|
||||
{
|
||||
string[] _tdateiname = file.Split('/');
|
||||
string dateiname = _tdateiname[_tdateiname.Length - 1];
|
||||
string ordner = _tdateiname[_tdateiname.Length - 2];
|
||||
|
||||
client.DownloadFile(Path.Combine(destinationPath, ordner, dateiname), file, true, FluentFTP.FtpVerify.None, progress);
|
||||
client.DeleteFile(file);
|
||||
|
||||
}
|
||||
}
|
||||
catch(TimeoutException ex)
|
||||
{
|
||||
MessageBox.Show("Die anlage reagiert nicht!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ListFiles(FtpClient client, string directory)
|
||||
{
|
||||
foreach (FtpListItem item in client.GetListing(directory))
|
||||
{
|
||||
if (item.Type == FtpFileSystemObjectType.File)
|
||||
{
|
||||
filenames.Add(item.FullName);
|
||||
}
|
||||
else if (item.Type == FtpFileSystemObjectType.Directory)
|
||||
{
|
||||
ListFiles(client, item.FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user