|
I give up, this seems impossible without the UriBuilder class... Well since .NET 1.1 when they made Uri(string, bool) obsolete... So here is my question:
How do you build a System.Uri object in .NET compact framework that points to a "file://" scheme with passed query information?
I've tried every valid (not obsolete) constructor for System.Uri meaning:
* Uri(string)
* Uri(string, UriKind)
* Uri(base, string)
* Uri(Uri, Uri)
It didn't matter which I use because they don't have any affect on the outcome... Every constructor will escape the ? to hex as %3F which is not valid to use with query information!!!
I can do this fine with strings but if I pass a string to the WebBrowser control it'll convert the string to a Uri object and have the problem again. So I need to build the correct Uri object and pass it to the WebBrowser control.
MSDN says the following lie:
The Uri constructors do not escape URI strings if the string is a well-formed URI including a scheme identifier.
Proven by this example:(start a new smart device application and add this code to the form1.cs file)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DeviceApplication1
{
public partial class Form1 : Form
{
public int demoValue = 4;
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(this.Form1_Load);
}
void Form1_Load(object sender, EventArgs e)
{
Uri htmlFile = new Uri(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), UriKind.Absolute);
MessageBox.Show("htmlFile.AbsoluteUri=\r\n" + htmlFile.AbsoluteUri);
string properFormated = string.Format("{0}/DeviceApplication1/test.html?test={1}", htmlFile.AbsoluteUri, this.demoValue);
MessageBox.Show("properFormated=\r\n" + properFormated);
Uri fileWithQuery = new Uri(properFormated);
MessageBox.Show("fileWithQuery.PathAndQuery=\r\n" + fileWithQuery.PathAndQuery);
}
}
}
View your results and see my problem any suggestions? I'm desprate at the moment (this has been bothering me since April!)
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
Also from the documentation:
"The URI represented by a Uri instance is always in "escaped" form. The following characters are reserved:
- Semi-colon (";" )
- Forward slash ( "/")
- Question mark ( "?" )
- Colon ( ":" )
- At-sign ("@")
- Ampersand ( "&" )
- Equal sign ("=" )
- Plus sign ("+" )
- US Dollar sign ("$" )
- Comma (",")
To transform the URI contained in a Uri instance from an escape encoded URI to a human-readable URI, use the System.Uri.ToString method." Another thing you could do is call Uri.UnescapeDataString(someString), which will give you back your URI with the proper unescaped characters.
Life, family, faith: Give me a visit.
From my latest post: "A lot of Christians struggle, perhaps at a subconscious level, about the phrase "God of Israel". After all, Israel's God is the God of Judaism, is He not? And the God of Christianity is not the God of Judaism, right?"
Judah Himango
|
|
|
|
|
Well I need the Uri object to pass to the WebBrowser control. If you pass it a string it'll convert it to a Uri object thus escaping the string it will navigate to.
In the Normal framework you can use UriBuilder to make a URL with extra unescaped information that is parsed properly by the .PathAndQuery property.
Example: (use a new c# console project on the normal framework 2.0 or higher)
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int demoValue = 4;
UriBuilder ub = new UriBuilder("file://", "", -1, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/DeviceApplication1/test.html", string.Format("?test={0}", demoValue));
Console.WriteLine("Correct OutPut:\r\n{0}", ub.ToString());
Console.ReadLine();
}
}
}
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
It's amazing I've gone so long without knowing about UriBuilder. Thanks for that.
So your issue is only with the .NET Compact Framework? Interesting. I'm afraid I don't have an answer for this. Have you tried asking at the Mobile Development[^] forums? If this turns out to be a bug in the .NET Compact Framework, you ought to report this to the Microsoft Connect site.
Life, family, faith: Give me a visit.
From my latest post: "A lot of Christians struggle, perhaps at a subconscious level, about the phrase "God of Israel". After all, Israel's God is the God of Judaism, is He not? And the God of Christianity is not the God of Judaism, right?"
Judah Himango
|
|
|
|
|
Yes, UriBilder is handy as StringBuilder because Uri like String objects are immutable reference types, so if it is changed a new one is made.
Hmmm hadn't though about the Mobile Dev forum (never frequent there) I sort of assumed it was for native code, it'll be worth a shot I guess
Though I do hate to double post this
I do have MSDN support issues left over from the VS2k8 upgrage, think they give bug reports back
Not like I'd use them anyway... maybe a MVP might look at this
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
Hi,
I am trying to integrate my application with Serena TeamTrack. I am suppose to receive chinese characters from web service but I am receiving the string as "????????". The suggested solution is to override GetReaderFromMessage method and setting the reader's
encoding to UTF-8 in Visual Studio 2005 C#. But I could not find this method any where. Can any one guide me how and where to override this method?
Thanks
|
|
|
|
|
Dear readers!
I am using .net studio 2003,
I have a form that I designed couple of month ago.
Now I was asked to use this from for another purpose.
What I want is to add a panel to this existing form, attach the existing controls to this panel and add another panel to design another view to this form.
After attching the existing controls to this panel I will be able to play with Bring To Front and Send to back properties to design the 2 views of this form.
The problem is that after adding this panel to the existing form the only way to attach existing controls to the panel is by draging them out of the form and draging them back over the panel, after doing that they are attched to the panel.
I need to follow this process for every control, and I am loosing their exact location then before I have started to add the panel.
If anyone knows how to tell an existing control you are attched to a specific panel in windows designer that will be very helpful
Thank you
Zvika
|
|
|
|
|
Press these keys in VS 2k3
[Ctrl] + [Alt] + [T]
Something called the Document Outline Windows should appear (least I think it is in 2k3...) I only have 2k8 and 2k5 installs on this PC. If this doesn't work I'll let you know when I get home, as my laptop has 2k3 installed.
The document outline allows you to position the hierarchy of your winforms in a tree-view format.
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
Hi
Can anyone tell me, how we can find the our system connected to the WEB with C#?
Thanks
Sorry for my English. I'm a freshman .
|
|
|
|
|
Please clarify what you are trying to do, your question makes no sense.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
OK, thanks Ashfield.
I'm using dial up modem for connecting to Internet. Now I want to write a program that detect, when my computer connected to Internet.
Do you understand what I mean ?
Sorry for my English. I'm a freshman .
|
|
|
|
|
I understand now. The only way I know of (and its a long time since I needed to do this) is to try and open a web page (say google.com) and trap any error messages. There may be other ways, as I say its a long time since I needed to do it.
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
M-Dayyan,
The simplest way (probably) would be to ping an internet address, and if something comes back, you have the internet.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
In the System.Net.NetworkInformation namespace check out the NetworkInterface and NetworkChange classes.
The NetworkChange has the NetworkAvailabilityChanged event. I think that is what you want.
|
|
|
|
|
Thanks Zoltan .
Can you explain more, I'm new in C#.
Thanks in advance ...
Sorry for my English. I'm a freshman .
|
|
|
|
|
Read this article here[^]
|
|
|
|
|
Thanks Zoltan .
Sorry for my English. I'm a freshman .
|
|
|
|
|
I am using the Free Image library to implement the .pcx image format into my image conveter application. Anyone care to help? THe main problems are The Out of Memory exception and I'm not sure if the library has the availible methods needed to be compatible with the program.
|
|
|
|
|
When do you receive the OutOfMemoryException?
Life, family, faith: Give me a visit.
From my latest post: "A lot of Christians struggle, perhaps at a subconscious level, about the phrase "God of Israel". After all, Israel's God is the God of Judaism, is He not? And the God of Christianity is not the God of Judaism, right?"
Judah Himango
|
|
|
|
|
During runtime when trying to convert a .pcx image to another image type..It happens when I load the pcx imgage into memory to be converted..
|
|
|
|
|
Chrisfrmatl wrote: en I load the p
Can you show us some code and point the exact line where it occurs? I've seen OutOfMemoryExceptions occur because some GDI object (such as a Bitmap) is in the wrong format, or is an invalid GDI object.
Life, family, faith: Give me a visit.
From my latest post: "A lot of Christians struggle, perhaps at a subconscious level, about the phrase "God of Israel". After all, Israel's God is the God of Judaism, is He not? And the God of Christianity is not the God of Judaism, right?"
Judah Himango
|
|
|
|
|
|
Hello All,
Can anybody tell me how can I send a Cancellation meeting request using smtp mail.
Thanks
Alok...
|
|
|
|
|
|
I doubt SMTP can do that. It will be implementation specific. So go ask the people who wrote the server app.
|
|
|
|