Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.IO;
- namespace CMD_Tchat
- {
- class Program
- {
- string date;
- string filePath;
- static void Main(string[] args)
- {
- Program program = new Program();
- program.date = (DateTime.Now.Day + "." + DateTime.Now.Month + "." + DateTime.Now.Year);
- try
- {
- if (!File.Exists(@"c:\programdata\cmd_tchat\" + program.date + ".txt"))
- {
- File.Create(@"c:\programdata\cmd_tchat\" + program.date + ".txt");
- return;
- } else
- {
- program.filePath = (@"c:\programdata\cmd_tchat\" + program.date + ".txt");
- }
- } catch (DirectoryNotFoundException)
- {
- Directory.CreateDirectory(@"c:\programdata\cmd_tchat");
- return;
- }
- string inputFilePath = @"D:\Vrac\lol.txt";
- string ftpHost = "127.0.0.1/";
- string ftpFilePath = (program.date + ".txt");
- string ftpFullPath = "ftp://" + ftpHost + ftpFilePath;
- using (WebClient request = new WebClient())
- {
- request.Credentials = new NetworkCredential("spylx", "");
- byte[] fileData;
- try
- {
- fileData = request.DownloadData(ftpFullPath);
- } catch
- {
- Console.WriteLine(ftpFullPath);
- Console.WriteLine(program.filePath);
- request.UploadFile(ftpFullPath, program.filePath);
- return;
- }
- using (FileStream file = File.Create(inputFilePath))
- {
- file.Write(fileData, 0, fileData.Length);
- file.Close();
- }
- Console.WriteLine("Download Complete");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement