如何从Windows应用程序中点击URL? [英] how can I hit the URL from windows application ?.
问题描述
我正在使用Windows应用程序,它将文件转换为字节并将此转换的字节发布到我想要访问这些转换后的字节的URL,并且在访问后我想将其转换回原始形式.....
这里是windows窗体的代码。
i am working on windows application which converts the file into bytes and post this converted bytes to the url where i want to access these converted bytes and after accessing i want to convert it back to its origional form.....
here is the code of windows form .
byte[] bytes = System.IO.File.ReadAllBytes("E:\\Asim Pics\\At Home\\DSC_0000084.jpg");
//System.IO.File.WriteAllBytes("E:\\asim.jpg", bytes);
string url = "http://localhost:55937/binary-conversion/frm-conversion.aspx? q=" + bytes + "";
//for hitting a specific url i am using this line
System.Diagnostics.Process.Start(url);
和在aspx页面我使用此代码访问我从Windows窗体发布的文件....
and in aspx page i m using this code to access that file which i posted from windows form ....
<pre lang="cs">string file = Request.QueryString["q"];
byte[] asdf = Convert.ToByte(file);
System.IO.File.WriteAllBytes(@"E:\usman.jpg", asdf);
但是当我尝试将此文件转换为字节时我得到一个错误....这是我们传输文件的poosible通过url命中然后从aspx页面访问它并处理它?????
but i m getting an error when i try to convert this file to the bytes.... is this poosible that we transfer a file through url hitting and then access it from aspx pages and work on it ?????
推荐答案
你必须将这些字节转换为base64字符串,如下所示: br />
You have to convert those bytes into a base64 string like follows:
string url = "http://localhost:55937/binary-conversion/frm-conversion.aspx?q=" + Convert.ToBase64String(bytes);
然后在你的asp.net代码中你必须这样做:
then in your asp.net code you have to do this:
byte[] asdf = Convert.FromBase64String(file);
这篇关于如何从Windows应用程序中点击URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!