|
I have an IPAQ PDA and I want to write a c# code which uses a image file that must be downloaded over internet by giving the url. I tried
WebClient Client = new WebClient ();
Client.DownloadFile("http://www.xxxx.com/image.jpg", " image.jpg");
but compact framework doesn't cover WebClient class.
So how can I handle it with httpwebrequest class or any other class???
By the way, how can I just directly put it on the screen? without using memory, I mean I dont want it to be written on harddisk.
thanks...
|
|
|
|
|
Hello,
I am very new to C#, so please bear with me.
Currently we are creating an application which contains controls that are created and added dynamically to the application based on user profile.
We have created a separate DLL where a list of images are added to the resource (via imageList, through image stream) and the images are managed there. In the application, image-access is encapsulated by the DLL. In essense, we have code that looks like this in the main application:
myUserControl.Image = ImageManager.getInstance().getImage( IMAGE_TYPE_CONSTANT );
Is this common practice? How else would you abstract the image-access from the application? What are the pros and cons of this, and other, methods?
Thank you very much,
James
|
|
|
|
|
In c# resources are not numbered with constants. See ResourceManager[^].
Embedding and using resources in c#[^]
I don't have much time for detailed explanations. I hope the links help you.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Thank you for your reply! We will proceed from the links you gave and see how we can resolve the issue, thanks again!
|
|
|
|
|
Hi...
I have made an listbox and a button to save the items inside the listbox into an xml document.
My code looks like this -->
System.Xml.XmlDataDocument data = new System.Xml.XmlDataDocument();
string CurrentUser = "someone";
string xml;
int count = this.listBoxMusik.Items.Count;
xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
xml += "<GreenSheep>";
xml += "<bruger>" + CurrentUser + "</bruger>";
xml += "<dato>" + DateTime.Now.ToLongDateString() + "</dato>";
xml += "<tid>" + DateTime.Now.ToLongTimeString() + "</tid>";
xml += "<sang>";
for(int i = 0; i < count; i++)
{
xml += "<nummer id=\"" + i.ToString() + "\">" + this.listBoxMusik.Items[i].ToString() + "</nummer>";
}
xml += "</sang>";
xml += "</GreenSheep>";
data.LoadXml(xml);
data.Save(@c:\);
data.RemoveAll();
this work great when i have about 10-20 items in the listbox, but if i add about 1200 items it trows an error!
System.Xml.XmlException: An error occurred while parsing EntityName Line 1, position 7691.
Can anyone tell me why this error comes when i add more than 1000 items?
thanks!
QzRz
|
|
|
|
|
First thing that comes to mind is XmlTextWriter - designed specifically for what you are trying to do.
this.listBoxMusik.Items[i].ToString() is probably returning a string that is messing up your xml
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Can you tell me what to do then?
if it makes problems is there another way to add the text from the listBoxMusik.Item[i] ?
Is it posible to add it to a string first and then add it to the xml?
QzRz
|
|
|
|
|
What i was saying is that ToString() of the item might be returning characters that are not valid -> which makes a mess.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
I search the internet for few examples of accessing the registry and most of them were similar. One that I tried was as follows:
//add line
using Microsoft.Win32;
//open regitry
RegistryKey OurKey = Registry.LocalMachine;
OurKey = OurKey.OpenSubKey("SOFTWARE\\MyReg",true);
//create a sub key
OurKey = OurKey.OpenSubKey("SOFTWARE\\MyReg\\NewReg",true);
OurKey.CreateSubKey("NewKey");
Every thing works up to this points, but when I try to set some valuse for "NewReg" with following line, it still compiles w/no errors but I get an error when run the application
OurKey.SetValue("one","myVal");
or
//OurKey.SetValue("one",(string)"myVal");
ERROR:
Excepttion of type "System.NullReferenceException"
"Object not set to an instance of an object"
any help will be greatly appreciated
|
|
|
|
|
Use debugger to step through your code. Problem is that OurKey is null.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
This one is working fine:
RegistryKey OurKey = Registry.LocalMachine;
OurKey = OurKey.OpenSubKey("SOFTWARE\\",true);
//create a sub key
OurKey = OurKey.CreateSubKey("NewKey");
OurKey.SetValue("one","myVal");
OurKey is null when you are asking to open key, that does not exists. So - check this every time when opening a key - if return value is null, you have to create this key first.
One more thing - each key operation with registry (Open, Create etc.) has return value RegistryKey, so don't forget to assign your key to return value. In your example - when you're Creating SubKey - you do not have return value. That's you mistake.
Hope it'll help.
Robin Panther
|
|
|
|
|
I have build a C# application that has on one of the form a web browser control that diplays various xml files transformed to html via xslt file. I have been trying for ever to control events fired by user intraction on these web pages to be handled in the Form hosting the browser. Anyone has figured this out?
Elie
|
|
|
|
|
Please explain a little more...
If you want to call c# methods from your page hosted in ie - you can use javascript to call c# methods through window.external.methodname. You need to implement IDocHostUIHandler... There's a nice article on CP: http://codeproject.com/csharp/winformiehost.asp[^]
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Thank you Alex for your response. I will check it out. I guess I go this way as a workaround. Actually, my issue was trapping html document events (for instance the A tag onclick event). In other words, I wanted to find out how to trap html element events of a document loaded inside web browser in a C# application. I have found some articles to that meaning, however, no concrete examples for me to proceed with.
Elie
|
|
|
|
|
Hello Alex, the article you suggested was very helpful. However, when I downloaded the sample project I could not get it to run. I could not find the reference MsHtmHstInterop. Have you been able to get it to work? Can you let me know how?
Elie
|
|
|
|
|
I have been able to get it to work. It sure is cool.
IIRC this article can help you: http://www.codeproject.com/csharp/advhost.asp
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hello Alex,
I have gotten it to partially work. It works fine when the browser control loads an html file. However, when I load an xml file it does not work. Find below a sample of the xslt file I use to transform my xml files:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:include href="WordTablesSig.xslt">
<xsl:output method="html">
<xsl:template match="PARAGRAPH">
<title>Sader Law Compandiom
var elementId;
function ElementClicked(NodeElementId)
{
elementId = NodeElementId; window.external.WinFormIe(NodeElementId);
}
<xsl:if test="parent::node()/@SHOW='1'">
When the element is clicked, I get "Object does not support property of method" error inside the ElementClicked function
Elie
|
|
|
|
|
Never mind I just need to call parent object of the window before calling external.
thx
Elie
|
|
|
|
|
ok i installed directx 9 sdk and i am trying to add ref to microsoft.directx but i can find in it like it's not installed or at least csharp can't see it so i went looking in the dxsdk directory and i found it microsoft.directx.dll in a cab file but that was the only play i saw it and i can't find it anywhere else on my computer can somebody help me
thanks
chad
|
|
|
|
|
Hi,
1)
I have some problem with application project, i'll create webservice to communicate with database and at this moment client request for data and recive dataset prepared by ws, so it's not a problem when database is small but when database is large ex 30 000 records, it'll be to much data to send over internet, so i use the examle which use a stored procedure to take the part of data using page number and page size requested by client. This resolution is good but it base on a id's field (number format) and recive data in "from-to" format (ex. from 11 to 20, page size 10, page number 2), but what if you use a text format key field in data table (ex. SI342)??? so my question is it's different way to pagging dataset???
2)
second problem what i have is: when i get next page, i set new dataset as a datasource so in datagrid is not a problem because it's one line to bind all, but in contrlos like textbox i must clear binding and set the new, it's different way to rebind datasource in controls????
please help me in this problem, maybe some link to good example.
see ya,
KrisPL
krzysztofo@poczta.onet.pl
|
|
|
|
|
How can I reassign a key value in a hashtable given a condition? Eg.
foreach(DictionaryEntry E in My_HT) //[Key string]{value int}
{
if(((int)_E.Value)!=1)
((string)_E.Key)=”NOT 1”;//this line gives the error
}
this code gives me “The left-hand side of an assignment must be a variable, property or indexer” and as far as I can tell _E.Key is a property. According to intelisence it has both get and set ability. Can some one tell me why it doesn’t work.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
You can't cast the left-hand side of an assignment.
The left hand side must be an variable to store the value in, not an complex expression (cast).
Or what would you think the compiler should do with an assignment like a + b = 1 ?
You need to cast the right hand side,
_E.Key = (object)"NOT 1";
but as a cast to object is always implicit, you can also use
_E.Key = "NOT 1";
But DictionaryEntry is a structure, so changing it's key property won't change the key actually used by the hash table.
|
|
|
|
|
The other reply states why, but also, you're not supposed to change the contents of an enumeration WHILE enumerating it.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Luis Alonso Ramos wrote:
you're not supposed to change the contents of an enumeration WHILE enumerating it.
He is modifying the content of the content, but that is a struct, so it wil have no effect, also he changes the key and if that worked, it would cause collisions. And lastly he is refering to some variable (_E , not E) outside the foreach.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
leppie wrote:
And lastly he is refering to some variable (_E , not E) outside the foreach.
You're right! I didn't see that. Sorry!
leppie wrote:
He is modifying the content of the content,
He is modifying the content of the DictionaryEntry object, not adding or removing a DictionaryEntry itself. But what I mean is that he's modifying the entry's Key property, which I believe is used to index the Hashtable (or at least is more imporant than other properties). So, if he's modifying that, to some extent he is modifying the enumeration. You mention it, what if he causes a Key collision?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|