|
Hi,
I want to search a specific string in .txt file and copy that string in to another file. How can i do this in C#?
|
|
|
|
|
Try this out:
StreamReader reader = new StreamReader("c:\\test.txt");
String line = "";
while(line != null)
{
line = reader.ReadLine();
if(line.IndexOf("is line two") != -1)
{
StreamWriter writer = new StreamWriter("c:\\testOut.txt");
writer.Write("found!");
writer.Close();
break;
}
}
|
|
|
|
|
Hi everyone,
I just wanna know how do u compare a password with the one given in the login form when its been encrypted with MD5 technique. How can u check that the user has entered correct password.
thanks
Rocky
|
|
|
|
|
Rocky71 wrote: I just wanna know how do u compare a password with the one given in the login form when its been encrypted with MD5 technique. How can u check that the user has entered correct password.
By encrypting (or, to be accurate, hashing) the password that the user typed in then comparing the two MD5 hash values.
|
|
|
|
|
I need to start a Webbrowser and control it's behaviour afterwards (Navigate, show/hide menu...). To simply call iexplore.exe with an URL or use the WebBrowser-Control is not an option
Previous to C# I used the IWebBrowser2-Interface out of SHDocVw which worked just fine, I tried to do the same C# but every time I want to .Navigate I got a ComException with HRESULT of 0x80004005 (E_FAIL).
Anybody got an idea?
Thanks in advance
|
|
|
|
|
I did something of this sort with the WebBrowser control in VS 2005. But this is just a control and does not open IE in a separate window. You need to develop a windows form which has this control embedded. You can control almost all the navigation and display options of IE using the methods and properties of the control.
Regards
SG
|
|
|
|
|
Thank you for the answer, I tried several possibilities and nothing worked as wanted. I will stick to your solution, it's the easiest and fastest way
Regards
apet
|
|
|
|
|
Hi.
I have this problem, i can't figure out what i should do.
I want to make an application where i can insert people to a database.
I'm using textboxes to write info about the person and so on.
And i want it all into a database where i can edit it again after..
Please help me, i hope you understand what i'm writing..
I'm new at this..
|
|
|
|
|
|
Please tell what the problem you are facing. We are not here to write code for you. Supply code snippet or scinario which you are facing problem.
I suggest you should try google first and see how database connection works with c# application and so on.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Stoumann wrote: ease help me, i hope you understand what i'm writing..
Your question was easy enough to understand, unfortunately it is not one that can be answered in a single post.
Stoumann wrote:
I'm new at this.
Everyone has to start somewhere! At least you have not shosen a ridiculously difficult first project like "I want to write a face recognistion service that interops with 2 cameras to track movement "
Start by lookin g into ADO.NET - this provides you with database access capabilities. You could also look at DataBinding if its a windows forms app, otherwise look at ASP.NET page lifecycle to discover how to link web controls to data drawn from a database.
|
|
|
|
|
hey Stoumann are you a new Developer.
Have you ever heard of the ADO.Net or just did you google that how to insert people to database using C#.
So first try to google it and get the Articles there are lot of articles are there.
SO try with the articles and then if you have got any problem ie., error tell here.we will help you in solve that problem.
this is not a single step answer to tell in this regards.
Regards,
Satips.
|
|
|
|
|
Hello everybody!
Can someone tell me why the following code comes to the conclusion that using an event instead of a direct method call is about 3 times faster????
Its pretty simple, just copy it at give it a go!
------------------------------------------
public class Class1
{
event TestDelegate TestEvent;
delegate void TestDelegate(String test);
public static void Main(String[] args)
{
//Number of cycles
int n = 10000000;
Class1 c = new Class1();
//register events
c.TestEvent += c.Test;
c.TestEvent += c.Test1;
c.TestEvent += c.Test2;
Console.WriteLine("Calling event {0} times....", n);
DateTime startTime = DateTime.Now;
//Call the event n times
for (int i = 0; i < n;i++ )
{
if(c.TestEvent != null)
c.TestEvent("i = " + i);
}
DateTime stopTime = DateTime.Now;
TimeSpan duration = stopTime - startTime;
Console.WriteLine("Calling normal {0} times....", n);
startTime = DateTime.Now;
//Call the event n times
for (int i = 0; i < n; i++)
{
c.Test("i = " + i);
c.Test1("i = " + i);
c.Test2("i = " + i);
}
stopTime = DateTime.Now;
TimeSpan duration2 = stopTime - startTime;
Console.WriteLine("Event based call took: {0},{1} sec", duration.Seconds, duration.Milliseconds);
Console.WriteLine("Normal call took: {0},{1} sec", duration2.Seconds, duration2.Milliseconds);
double eventTime = duration.Seconds*1000 + duration.Milliseconds;
double normalTime = duration2.Seconds*1000 + duration2.Milliseconds;
Console.WriteLine("Normal calling is about {0} times faster.", eventTime/normalTime);
Console.ReadLine();
}
private void Test(String test)
{
//do sth
int i = 0;
int x = i * 2;
}
private void Test1(String test)
{
//do sth
int i = 0;
int x = i * 2;
}
private void Test2(String test)
{
//do sth
int i = 0;
int x = i * 2;
}
}
------------------------------------------
Thanks in advance!
|
|
|
|
|
Hi,
the difference is
c.Test("i = " + i);
c.Test1("i = " + i);
c.Test2("i = " + i);
does generate three new strings, whereas c.TestEvent("i = " + i);
generates only one.
|
|
|
|
|
Your right, of course! Thanks!
So with the application changed, the result is that using the event mechanism is about 7% slower (for my example application). This seams reasonable.
Steffen
|
|
|
|
|
A main hashtable is populated with a Dictionary entry and several other hashtables with keys and values.
Now I would like to loop through the main hashtable and retrieve the value of each key in each item i.e. hashtables and Dictionary item.
This is what I am trying to do but it gives an error because the first item in the main hashtable is a disctionary entry.
Thanks
foreach (Hashtable ht in Globals.CacheHashTablesMain)
{
}
|
|
|
|
|
Hello,
You have to look for DictionaryEntry in Hashtable.
foreach(DictionaryEntry de in YourHT)
{
//de.Key
//de.Value
}
All the best
Martin
-- modified at 7:57 Tuesday 8th May, 2007
|
|
|
|
|
Hi,
please note that each hashtable inside the main hashtable has many items.
so I think de.value does not work.
Thanks
|
|
|
|
|
Hello,
Ok, I didn't got your question write at first.
You have to iterate to the main hashtable and cast the falues to Hashtable and iterate again threw that, to get your items.
foreach(DictionaryEntry de in MainHashtable)
{
Hashtable subHT = de.Value as Hashtable;
if(subHT!=null)
{
foreach(DictionaryEntry deSub in subHT)
{
}
}
}
To make it look a little more OOP, you could create a recursive method call, but in this special case it's not neccesary as it is not to abstract.
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi,
It does not pick up the items in the first loop which is dictionary as opposed to hashtable.
|
|
|
|
|
Hello,
arkiboys wrote: It does not pick up the items in the first loop which is dictionary as opposed to hashtable
Sorry, I don't understand what you want to say.
What I understood, is that you have a hashtable full of hastables (subHT) in the Value property.
These subHT store the items you would like to have also in the Value property.
You are not able to get these items over the Key.
Please post the code snipped you have write now!
All the best,
Martin
|
|
|
|
|
Hi,
I need a masked(formatted) edit box in C#, where i can enter the date time like "month/date/year Hours:Minutes:Secods AM/PM" for example "5/9/2007 12:00:00 AM", does any one know how can i do that.
Warm Regards,
Mushq
|
|
|
|
|
See this[^]
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Try a DateTimePicker instead.
|
|
|
|
|
Hi,
Maybe Smart FieldPackEditor.Net would fit your need. The component is in beta but it is the only flexible DateTimePicker replacement on the scene.
|
|
|
|