private async void DoDownloadOrUpload(bool isDownload) { Uri uri = new Uri(HostTextBox.Text); StatusTextBlock.Text = "Connecting."; FtpClient client = new FtpClient(); await client.ConnectAsync( new HostName(uri.Host), uri.Port.ToString(), UserTextBox.Text, PassTextBox.Text); if (isDownload) { StatusTextBlock.Text = "Downloading."; byte[] data = await client.DownloadAsync(uri.AbsolutePath); ContentTextBox.Text = Encoding.UTF8.GetString(data, 0, data.Length); } else { StatusTextBlock.Text = "Uploading."; byte[] data = Encoding.UTF8.GetBytes(ContentTextBox.Text); await client.UploadAsync(uri.AbsolutePath, data); } StatusTextBlock.Text = "Done."; }
private async void DoDownloadOrUpload(bool isDownload) { //Uri uri = new Uri(HostTextBox.Text); //StatusTextBlock.Text = "Connecting."; //FtpClient client = new FtpClient(); //await client.ConnectAsync( // new HostName(uri.Host), // uri.Port.ToString(), // UserTextBox.Text, // PassTextBox.Text); //if (isDownload) //{ // StatusTextBlock.Text = "Downloading."; // byte[] data = await client.DownloadAsync(uri.AbsolutePath); // ContentTextBox.Text = Encoding.UTF8.GetString(data, 0, data.Length); //} //else //{ // StatusTextBlock.Text = "Uploading."; // byte[] data = Encoding.UTF8.GetBytes(ContentTextBox.Text); // await client.UploadAsync(uri.AbsolutePath, data); //} //StatusTextBlock.Text = "Done."; FtpClient client = new FtpClient(); await client.ConnectAsync( new HostName("191.232.241.35"), "21", "UsrFtpMobile", "v5Y5SwuNebuhASup4ju8ar3y4navuvu6"); byte[] data = Encoding.UTF8.GetBytes("Hello world!"); await client.UploadAsync("/bdar.txt", data); }