私はXamarinとC#worldで新しく、FTPサーバーに画像をアップロードしようとしています。私はFtpWebRequestクラスを見ましたが、私は正しいことを得ていません、プラタフォーム固有のコードを挿入する方法はわかりませんし、実際には何を意味するのか分からず、既にこのビデオを見ていましたが(https://www.youtube.com/watch?feature=player_embedded&v=yduxdUCKU1c)これを使ってFtpWebRequestクラスを作成し、画像をアップロードする方法を見てください。PCL Xamarinフォームを使用してFTPサーバーに画像をアップロード
私はこのコード(ここでは:https://forums.xamarin.com/discussion/9052/strange-behaviour-with-ftp-upload)を送信して画像を送信し、使用できません。
public void sendAPicture(string picture)
{
string ftpHost = "xxxx";
string ftpUser = "yyyy";
string ftpPassword = "zzzzz";
string ftpfullpath = "ftp://myserver.com/testme123.jpg";
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
//userid and password for the ftp server
ftp.Credentials = new NetworkCredential(ftpUser, ftpPassword);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
FileStream fs = File.OpenRead(picture);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();
ftpstream.Flush();
// fs.Flush();
}
私はタイプのFileStream、WebRequestMethodsやファイルを持っていない、また、「私たFtpWebRequestクラスは、「キープアライブ」、「UseBinary」と「GetRequestStream」方法を、持っているdoens'tと私のStreamクラスはありません。メソッドを閉じます。
マイたFtpWebRequestクラス:
公共密封されたクラスたFtpWebRequest:WebRequestクラス { 公共オーバーライド文字列ContentTypeを { 取得 { スロー新しいNotImplementedException(); }
set
{
throw new NotImplementedException();
}
}
public override WebHeaderCollection Headers
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override string Method
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override Uri RequestUri
{
get
{
throw new NotImplementedException();
}
}
public override void Abort()
{
throw new NotImplementedException();
}
public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
{
throw new NotImplementedException();
}
public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state)
{
throw new NotImplementedException();
}
public override Stream EndGetRequestStream(IAsyncResult asyncResult)
{
throw new NotImplementedException();
}
public override WebResponse EndGetResponse(IAsyncResult asyncResult)
{
throw new NotImplementedException();
}
}
(私が知っている、私はそこに書くことかわからないので、私は、そこだけ押されたのctrl +を何も書いていなかった)
誰でも提供することができません私はFtpWebRequestクラスの完全なサンプルですか?私は上記のような使用クラスを見つけるだけです。