急啊,大家知道在Winform下怎么进行URL编码吗? 郁闷啊,使用WebRequest时有中文,得不到要的内容我把地址栏内已编码过的字串放进去就能得到内容请问在WINFORM下怎么对字串进行URL编码很急,哪位大哥知道,告诉小弟啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用 System.Uri.HexEscape() 方法 另外, System.Web.HttpUtility.UrlEncode() 也可以用. 谢谢,我先试试System.Uri.HexEscape() System.Web.HttpUtility.UrlEncode()好像在Winform下不能使用啊 555,有错代码: string src = "张韶涵"; char[] tes = src.ToCharArray(); src = ""; foreach(char tt in tes) { //src += System.Uri.HexEscape(tt).ToString(); MessageBox.Show(System.Uri.HexEscape(tt).ToString()); }错误:有关调用实时(JIT)调试而不是此对话框的详细信息,请参阅此消息的结尾。************** 异常文本 **************System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。参数名: character at System.Uri.HexEscape(Char character) at WindowsApplication3.Form1.Start_Click(Object sender, EventArgs e) in d:\ewebapp\edownload\edownload\windowsapplication3\form1.cs:line 456 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)************** 已加载的程序集 **************mscorlib 程序集版本: 1.0.5000.0 Win32 版本: 1.1.4322.573 基本代码: file:///d:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll----------------------------------------WindowsApplication3 程序集版本: 1.0.2094.41375 Win32 版本: 1.0.2094.41375 基本代码: file:///D:/eWebapp/eDownLoad/eDownLoad/WindowsApplication3/bin/Debug/WindowsApplication3.exe----------------------------------------System.Windows.Forms 程序集版本: 1.0.5000.0 Win32 版本: 1.1.4322.573 基本代码: file:///d:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll----------------------------------------System 程序集版本: 1.0.5000.0 Win32 版本: 1.1.4322.573 基本代码: file:///d:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll----------------------------------------System.Drawing 程序集版本: 1.0.5000.0 Win32 版本: 1.1.4322.573 基本代码: file:///d:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll----------------------------------------System.Xml 程序集版本: 1.0.5000.0 Win32 版本: 1.1.4322.573 基本代码: file:///d:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll----------------------------------------mscorlib.resources 程序集版本: 1.0.5000.0 Win32 版本: 1.1.4322.573 基本代码: file:///d:/windows/assembly/gac/mscorlib.resources/1.0.5000.0_zh-chs_b77a5c561934e089/mscorlib.resources.dll----------------------------------------System.Windows.Forms.resources 程序集版本: 1.0.5000.0 Win32 版本: 1.1.4322.573 基本代码: file:///d:/windows/assembly/gac/system.windows.forms.resources/1.0.5000.0_zh-chs_b77a5c561934e089/system.windows.forms.resources.dll----------------------------------------************** JIT 调试 **************计算机的配置文件(machine.config)的 system.windows.forms 节中必须设置 jitDebugging 值。编译应用程序时还必须启用\r\n调试。\r\n\r\n例如: \r\n\r\n<configuration>\r\n <system.windows.forms jitDebugging="true" />\r\n</configuration>\r\n\r\n启用 JIT 调试后,任何未处理的异常\r\n都将被发送到此计算机上注册的 JIT 调试器,\r\n而不是由此对话框处理。\r\n using System.Windows.Forms;public class Test : Form{ static void Main() { string src = "张韶涵"; string msg = System.Web.HttpUtility.UrlEncode(src); MessageBox.Show(msg); }} 嗯好了,引用了System.Web名称空间后就可以使用System.Web.HttpUtility.UrlEncode但我在想,winform本身也可以做到的,url中文编辑应该就是把汉字转字16进制吧. windows服务调用EXE,托盘程序没有弹出 为何我修改不了COOKIE???可以读取 VS2008自带水晶报表打印问题 如果让一个窗体始终在另一个窗体之前 在visual c#程序中如何起一个进程来完成拷贝功能 计算机如何识别u盘,大侠们请进啊~ 求教 :如何获得其它进程窗口中的控件字体? DataGrid自动创建列的问题! 我在程序中调用了存储过程,编译也通过了。但在使用时,总是提示我没有给@value提供参数让我很不解。高手,能参详一下吗 一个关于windows service的问题 一个多参数查询的问题 C#开发window应用程序连接数据库的问题?
System.Web.HttpUtility.UrlEncode()好像在Winform下不能使用啊
代码:
string src = "张韶涵";
char[] tes = src.ToCharArray();
src = "";
foreach(char tt in tes)
{
//src += System.Uri.HexEscape(tt).ToString();
MessageBox.Show(System.Uri.HexEscape(tt).ToString());
}
错误:
有关调用实时(JIT)调试而不是此对话框的详细信息,
请参阅此消息的结尾。************** 异常文本 **************
System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。
参数名: character
at System.Uri.HexEscape(Char character)
at WindowsApplication3.Form1.Start_Click(Object sender, EventArgs e) in d:\ewebapp\edownload\edownload\windowsapplication3\form1.cs:line 456
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///d:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
WindowsApplication3
程序集版本: 1.0.2094.41375
Win32 版本: 1.0.2094.41375
基本代码: file:///D:/eWebapp/eDownLoad/eDownLoad/WindowsApplication3/bin/Debug/WindowsApplication3.exe
----------------------------------------
System.Windows.Forms
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///d:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///d:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///d:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///d:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
mscorlib.resources
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///d:/windows/assembly/gac/mscorlib.resources/1.0.5000.0_zh-chs_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------
System.Windows.Forms.resources
程序集版本: 1.0.5000.0
Win32 版本: 1.1.4322.573
基本代码: file:///d:/windows/assembly/gac/system.windows.forms.resources/1.0.5000.0_zh-chs_b77a5c561934e089/system.windows.forms.resources.dll
----------------------------------------************** JIT 调试 **************
计算机的配置文件(machine.config)的
system.windows.forms 节中必须设置 jitDebugging 值。
编译应用程序时还必须启用\r\n调试。\r\n\r\n例如: \r\n\r\n<configuration>\r\n <system.windows.forms jitDebugging="true" />\r\n</configuration>\r\n\r\n启用 JIT 调试后,任何未处理的异常\r\n都将被发送到此计算机上注册的 JIT 调试器,\r\n而不是由此对话框处理。\r\n
{
static void Main()
{
string src = "张韶涵";
string msg = System.Web.HttpUtility.UrlEncode(src);
MessageBox.Show(msg);
}
}
但我在想,winform本身也可以做到的,
url中文编辑应该就是把汉字转字16进制吧.