C# 将图像作为字节数组上载到文件夹中的服务器

C# 将图像作为字节数组上载到文件夹中的服务器,c#,xamarin,C#,Xamarin,我的问题是如何将字节数组上传到服务器 我已经将其转换为字节数组,如下所示: Stream stream = ContentResolver.OpenInputStream(data.Data); Bitmap bitmap = BitmapFactory.DecodeStream(stream); MemoryStream memStream = new MemoryStream(); bitmap.Compress(Bitmap.CompressFormat.Jpeg, 50, memStre

我的问题是如何将字节数组上传到服务器

我已经将其转换为字节数组,如下所示:

Stream stream = ContentResolver.OpenInputStream(data.Data);
Bitmap bitmap = BitmapFactory.DecodeStream(stream);
MemoryStream memStream = new MemoryStream();
bitmap.Compress(Bitmap.CompressFormat.Jpeg, 50, memStream);                
byte[] picData;
picData = memStream.ToArray();

现在我想将picData上传到“pics”文件夹中的服务器上。

谁编写了服务器代码?如果需要,请添加列表。它是什么类型的服务器?您需要更具体一些。您想通过您编写的web服务或FTP等方式上载它吗?或者是网站上的代码,而你只是想将其保存到网站内的pics文件夹中?你的问题很简单。请提供尽可能多的信息,以便人们可以帮助您这里有几十个问题,以便已经解决这个问题-请在发布之前使用搜索您的尝试捕获实际上没有任何作用,这将是与根本没有任何尝试捕获相同的行为。为什么会有呢?
public string UploadToServer(byte[] image)
    {
        try
        {
            MemoryStream ms = new MemoryStream(image);
            var i = Bitmap.FromStream(ms);
            string time = DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss");
            string Filename = "IMG_" + time + ".png";
            string UploadPath = HttpContext.Current.Server.MapPath("~/Image");
            if (!Directory.Exists(UploadPath))
                Directory.CreateDirectory(UploadPath);
            string NewFilePath = Path.Combine(UploadPath, Filename);
            File.WriteAllBytes(NewFilePath, image);
            return Filename;
        }
        catch (Exception)
        {
            throw;
        }
    }