English 中文(简体)
• 如何从台式机向冲锋枪手播放双轨图像并接收图像?
原标题:How to post a binary image from desktop app to ashx handler and receive it?

我正在开发WinForms应用程序,并想向网络应用发送双面图像数据。 如何工作?

我将这一点编成法典:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";

request.AllowWriteStreamBuffering = true;
request.KeepAlive = true;                
request.Credentials = System.Net.CredentialCache.DefaultCredentials;

var fc = GetFileContent(varsayilanResimGuid);
byte[] postBytes = fc.Dosya;
request.ContentLength = postBytes.LongLength;
Stream requestStream = request.GetRequestStream();               
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();                

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string content = new StreamReader(response.GetResponseStream()).ReadToEnd(); 

以及我如何以.语接收这种双亲形象内容?

最佳回答

I question and I answer.
how to receive a binary image:

Stream gelenResim = context.Request.InputStream;

if (gelenResim.Length == 0) 
{
    e.Resim = "/Content/EmlakDetayImaj/Noimages.jpg";
}

string guidim = Guid.NewGuid().ToString().Substring(0, 4);
var KaydetResimDosya = "/Content/EmlakDetayImaj/" + guidim + ".jpg";

using (FileStream fileStream = System.IO.File.Create(context.Server.MapPath("~/Content/EmlakDetayImaj/" + guidim + ".jpg"), (int)gelenResim.Length))
{
    byte[] bytesInStream = new byte[gelenResim.Length];
    gelenResim.Read(bytesInStream, 0, (int)bytesInStream.Length);
    fileStream.Write(bytesInStream, 0, bytesInStream.Length);
}
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签