|
thanks buddy.
System.IO.File.Delete("path"); worked for me.
sAqIb
|
|
|
|
|
Great!
Kind regards - Jakob
*********************************************
Three kinds of people in the world:
- Those who can count..
- Those who can't!
10 kinds of people in the world:
- Those who understand binary
- Those who don't
|
|
|
|
|
how can i create mobile projects in C#?
|
|
|
|
|
|
Hi,
I want to transfer the file from client to server.
Just using IPadress only, here i dont use asp and web services.
Any one kindly guide me.
|
|
|
|
|
|
Hi All
We are using te code below for XML parsing, Its a bit slow, anybody knows fater XML parsing in c#?
As I am using for PocketPC, its taking for ever to parse.
please help.
public static ArrayList ParseURL(string strUrl)
{
ArrayList searchItems = new ArrayList();
mbitSearchItem currentSearchItem = new mbitSearchItem();
string lastElementName = "";
try
{
XmlTextReader reader = new XmlTextReader(strUrl);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Text:
switch (lastElementName)
{
case "id":
currentSearchItem.id = Convert.ToInt32(reader.Value);
break;
case "fsz":
currentSearchItem.size = Convert.ToInt32(reader.Value);
break;
case "fnm":
currentSearchItem.name = reader.Value;
break;
case "typ":
currentSearchItem.type = Convert.ToInt32(reader.Value);
break;
case "seed":
currentSearchItem.seeders = Convert.ToInt32(reader.Value);
break;
}
break;
case XmlNodeType.Element:
lastElementName = reader.Name;
//Console.WriteLine(lastElementName);
Hashtable attributes = new Hashtable();
string strURI = reader.NamespaceURI;
string strName = reader.Name;
if (reader.HasAttributes)
{
for (int i = 0; i < reader.AttributeCount; i++)
{
reader.MoveToAttribute(i);
attributes.Add(reader.Name, reader.Value);
}
}
StartElement(strURI, strName, strName, attributes);
break;
case XmlNodeType.EndElement:
if (reader.Name.Equals("item"))
{
searchItems.Add(currentSearchItem);
currentSearchItem = new mbitSearchItem();
}
break;
default:
break;
}
}
}
catch (Exception e)
{
Console.WriteLine("error occured: " + e.Message);
}
|
|
|
|
|
You may want to try to changing the xml data type of your integer values to be xsd:integer (or xsd:decimal) instead of converting the text types yourself. I've found the Convert functions to be fairly slow. In .NET 2 you can try
XmlReader.ReadContentAsInt Method. This, or something else to get rid of the ToInt32 calls, may be faster.
-- Bob
|
|
|
|
|
Hi Bob
I am implementing XmlReader.ReadContentAsInt Method.Now my application builds faster.
Thanks a lot
|
|
|
|
|
Perhaps I have a problem with public/private?
I have a Form generated in C#, the second Form called "MainForm" is included in the Project and visible in the projectexplorer, like a normaly generated Form.
But on de Code of Form1 or so, I can't access to "MainForm"? Its declared as public. I don't understand why MainForm.show etc doesnt work?
Any suggestions?
|
|
|
|
|
Because MainForm is a class name. You can't show a class, only an instance of a class.
private MainForm form;
...
form.Show();
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
That means i have to instanciate (or how its called in english) the class?
1. Has the class MainForm to be public or is that not necesarry?
2. How can i access to MainForm? Do I have to do this like :
Mainformfoo Mainform = new Mainformfoo();
I've read http://www.csharp-station.com/Tutorials/Lesson07.aspx[^] but I didn't see the solution... perhaps I'll change to VB
|
|
|
|
|
The class needs to be visible to where you're calling it from. The instance does not have to be public, no.
Yes, that's how you create an instance of the MainformFoo class. Remember, this is one instance, if you create OTHER instances, interacting with those will not effect the instance you created before. So if you want to change some property on your form, you can't just do the above to get an instance and call methods, that will not change any other instance in your code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I am trying to read a rss feed and create a linklabel for the items within a panel on a form. I have a class called LinkLabelArray and that has the following:
public void AddNewLinkLabel()
{
LinkLabel aLabel = new LinkLabel();
this.List.Add(aLabel);
Form1.ActiveForm.panel1.Controls.Add(aLabel);
//set linklabel properties
aLabel.AutoSize = true;
aLabel.LinkVisited = true;
aLabel.Visible = true;
aLabel.Top = 5;
aLabel.Height = 15;
aLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// handler for clicked event of news title label
aLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(ClickHandler);
}
I can't get the linkLabel to be added to the panel on my form (Form1). I have tried everything I can think of and I still get this error - 'System.Windows.Forms.Form' does not contain a definition for 'panel1' even though I have a panel on Form1 called panel1 and it's modifier value is set to public. public System.Windows.Forms.Panel panel1;.
Can someone please help me!
Thanks,
Al
|
|
|
|
|
The ActiveForm property returns an instance of System.Windows.Forms.Form class which contains no panel1 property as the error message clearly says. To access the panel1 variable you will need to cast the return value to your Form1 type but be sure that ActiveForm always returns a Form1 object.
((Form1)Form1.ActiveForm).panel1.Controls.Add(aLabel);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I'm trying to create an object that will deserialize xml into a dictionary. So far I have most of the stuff working however when I do something like
this.myList.Add(myItem);
I expect to get a new item that in my list that is equal to myItem. However, for some reason the List updates all of the containing items in the List to equal the most recently added item.
Any idea what's going on?
Here is a the serializable class in question if it helps:
public class WeatherCities : IXmlSerializable<br />
{<br />
[XmlElement]<br />
public List<city> City;<br />
public WeatherCities()<br />
{<br />
}<br />
<br />
public class city<br />
{<br />
private string cityName;<br />
private string cityCode;<br />
<br />
[XmlElement]<br />
public string CityName<br />
{<br />
get { return cityName; }<br />
set { cityName = value; }<br />
}<br />
<br />
[XmlElement]<br />
public string CityCode<br />
{<br />
get { return cityCode; }<br />
set { cityCode = value; }<br />
}<br />
<br />
const string NS = "http://www.develop.com/xml/serialization";<br />
<br />
[XmlElement]<br />
public IDictionary<string, string> LocalizedNames;<br />
<br />
}<br />
<br />
public void ReadXml(XmlReader r)<br />
{<br />
this.City = new List<city>();<br />
while (r.Read())<br />
{<br />
city myCity = new city();<br />
myCity.LocalizedNames = new Dictionary<string, string>();<br />
<br />
while (r.Name == "City")<br />
{<br />
if (r.NodeType == XmlNodeType.EndElement)<br />
r.Read();<br />
else<br />
{<br />
r.Read();<br />
bool bLocalizedNameFound = false;<br />
myCity.CityCode = "";<br />
myCity.CityName = "";<br />
myCity.LocalizedNames.Clear();<br />
while (!bLocalizedNameFound)<br />
{<br />
switch (r.Name)<br />
{<br />
case "CityName":<br />
myCity.CityName = r.ReadElementString();<br />
break;<br />
case "CityCode":<br />
myCity.CityCode = r.ReadElementString();<br />
break;<br />
case "LocalizedNames":<br />
bLocalizedNameFound = true;<br />
break;<br />
}<br />
}<br />
<br />
string locale = "";<br />
string localizedname = "";<br />
bool localefound = false;<br />
bool endlocalnamefound = false;<br />
<br />
r.Read();
r.Read();
<br />
while (r.NodeType != XmlNodeType.EndElement && !endlocalnamefound)<br />
{<br />
switch (r.Name)<br />
{<br />
case "Locale":<br />
locale = r.ReadElementString();<br />
localefound = true;<br />
break;<br />
case "LocalizedName":<br />
localizedname = r.ReadElementString();<br />
break;<br />
}<br />
<br />
if (localefound == true && localizedname != "")<br />
{<br />
myCity.LocalizedNames.Add(locale, localizedname);<br />
localefound = false;<br />
localizedname = "";<br />
}<br />
<br />
if (r.NodeType == XmlNodeType.EndElement && r.Name == "LocalName")<br />
{<br />
r.Read();
if (r.Name == "LocalizedNames")<br />
endlocalnamefound = true;
r.Read();
}<br />
}<br />
<br />
this.City.Add(myCity);<br />
}<br />
}<br />
}<br />
}<br />
<br />
public void WriteXml(XmlWriter w)<br />
{<br />
}<br />
public System.Xml.Schema.XmlSchema GetSchema()<br />
{<br />
return LoadSchema();<br />
}<br />
private System.Xml.Schema.XmlSchema LoadSchema()<br />
{<br />
return null;<br />
}<br />
<br />
}<br />
}
|
|
|
|
|
I think the problem is that you're always adding the same object or to be more specific a reference to the same object. Try moving the creation of the city object into the second while loop.
while (r.Read())
{
while (r.Name == "City")
{
city myCity = new city();
myCity.LocalizedNames = new Dictionary();
...
}
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hey that did the trick! Thanks so much. I will remmeber to use PRE next time to preserve indentation...sorry about that.
|
|
|
|
|
(I didn't even bother to look at all the code that you posted. You should use the pre tag when you post more than a few lines to preserve the indentation, or the code gets virtually unreadable.)
What you are describing is a common problem when you reuse the same object. What you add to the list is not a copy of the object that you have, but a reference to the object. The result is that you end up with a list full of references to the same object. You have to create a new object for every item.
---
b { font-weight: normal; }
|
|
|
|
|
how can make my program to be Close if i press in (Esc)
go to tray Icon if i press to (F9)
i want to do that at time not in some form and not in other ???
Palestine
|
|
|
|
|
for esc make your quit button as cancel button on the form property
or you can use the key press event of the form
|
|
|
|
|
Hey everybody
I have the WEIRDEST problem of all.
all of a sudden, out of the blue, VS studio started to hang and become not responding when I'm trying to open or create a new project.
It starts to load or create the project but than it just hangs and stops responding (not responding status). devenv.exe process gets stuck on 50%
(+-2), and thats it.
I also noticed that it doesn't happen in all projects, just ones with COM components in them. for instance, a project with BandObject from the article in this site (http://www.codeproject.com/csharp/BandObjects20.asp) whic I have used this MANY times before, but now it won't load. I also tried to redownload it, but it still doesn't work.
I tried to uninstall and reinstall, look for an answer in the web, but nothing works! the next step is reinstalling windows or even reinstall a fresh copy of windows (which everybody knows its a nightmare!) I'm out of ideas! HELP - Please!!!
|
|
|
|
|
Are you saying that even uninstalling and reinstalling VS doesn't fix the problem?
Cheers,
Vikram.
"whoever I am, I'm not other people" - Corinna John.
|
|
|
|
|
no, it doesn't work!
and I will ask in the lounge. I just thought that maybe because it happens only in a specific type of programs, maybe someone will know.
Thanks anyway
|
|
|
|
|
BTW, this isn't a programming question, so you might get better answers if you ask in the Lounge.
Cheers,
Vikram.
"whoever I am, I'm not other people" - Corinna John.
|
|
|
|