|
Nish [BusterBoy] wrote:
Just like you need the JRE to run that J thing
I think Nish was making some comment about that coffee flavored language....someone go tell him that talk like that isn't allowed here[Kidding ]
Nick Parker
|
|
|
|
|
Nick Parker wrote:
I think Nish was making some comment about that coffee flavored language....someone go tell him that talk like that isn't allowed here
ROTFLMAO Nick
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Where to find that!!!!!!
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
try here
http://www.msdn.microsoft.com/downloads/default.asp
then go to sw development kits/ms .net framework redistributable. you can get it from there. Also, I have heard that the .net redistibutable is available from Windows Update. I haven't seen this myself, maybe because I already have it on my machine but it's supposed to be there.
|
|
|
|
|
http://download.microsoft.com/download/.netframesdk/Redist/1.0/W98NT42KMeXP/EN-US/dotnetredist.exe
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
This code gives me the exception (don't remember exactly): "The instance object cannot be null"
Do you know whats wrong?? I don't think you'll need more code than this, because this is my exception!!
FileInfo fileInfo = new FileInfo(files[i]);
StreamReader streamReader = fileInfo.OpenText();
// Hela raden
string line;
do
{
line = streamReader.ReadLine();
// Does line contain "searchText"??
if(line.IndexOf(searchText) != -1)
{
listBox1.Items.Add(line);
}
}
while(line != null);
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
You need to check for line = null; before you look for the word. You put the check in at the bottom of the loop, but not before you use it
[Edit] If the idea of checking your break condition twice makes you uneasy you can do this
while(true)
{
line = streamReader.ReadLine();
if(line == null)
break;
....
} [/Edit]
James
Simplicity Rules!
|
|
|
|
|
Why not
while(line = streamReader.ReadLine())
{
}
???
Does C# not support that either ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian Graus wrote:
Why not
while(line = streamReader.ReadLine()){
???
You should be able to do this as long as you check
if(line == null)
break;
before doing any string manipulation. You can't manipulate a Null value.
Nick Parker
|
|
|
|
|
In C++, the whole point of
while(line = streamReader.ReadLine()){
is that it would break when line became Null. You're telling me this is another area that C# falls short of C++ ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
C# way is to do
while((line = streamReader.ReadLine()) != null)
{ }
much clean.
|
|
|
|
|
I thought that might be the case. It's NOT much cleaner, it simply follows the C# philosophy of making the programmer explicitly state their intentions, of assuming the programmer is an idiot.
However, at least it can be done in a similar manner. Thanks for the tip.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
|
streamReader.ReadLine() will return a null if the stream is at end. So, change the if to:
FileInfo fileInfo = new FileInfo(files[i]);
StreamReader streamReader = fileInfo.OpenText();
string line;
do
{
line = streamReader.ReadLine();
<font color="red">if ((line != null) && (line.IndexOf(searchText) != -1))</font>
{
listBox1.Items.Add(line);
}
}
while(line != null);
Crivo
Automated Credit Assessment
|
|
|
|
|
Thank you!
But now when I try to make the strings upper I get this exception:
"Object reference not set to an instance of an object"
I sound to me that the upperLine and upperSearchText are not constructed or something like that1!?!??!??
Here is the code:
FileInfo fileInfo = new FileInfo(files[i]);
StreamReader streamReader = fileInfo.OpenText();
// Hela raden
string line;
do
{
// Läs nu in rad för rad
line = streamReader.ReadLine();
string upperLine = line.ToUpper();
string upperSearchText = searchText.ToUpper();
// Testa och se om "searchText" finns innuti raden
if (line != null)
{
int ret = upperLine.IndexOf(upperSearchText);
if(ret != -1)
{
listBox1.Items.Add(line);
}
}
}
while(line != null);
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
You still are trying to access line after ReadLine() and before cheking it for null.
Crivo
Automated Credit Assessment
|
|
|
|
|
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
|
|
|
|
|
I want to make a Form Designer with some script function I will code but I want to know how can I compile the form the user will create in exe
anybody know how to do this ?
thanks
Jonathan Pouliot
ICQ 71682311
|
|
|
|
|
I'm not sure if this will answer your question, because I am not completely sure how deep your design issue is. There is an article written here that sounds similar to this where the user can compile the code they generate. Here is the link in a new window. C# Compiler
Nick Parker
|
|
|
|
|
normally when minimize an application,the app will disappear from the windows desktop and will place an item at the taskbar!
then how can i avoid it to place an item at the taskbar?
just have a notification icon,when i double-click the notification icon,the application will resume!
thanks!
|
|
|
|
|
Add a notify icon to your main form, then on minimize set the ShowInTaskbar property of the main form to false.
In the context menu for the NotifyIcon have an option to set the WindowState of the main form to Restore, and set the ShowInTaskbar property to true again.
HTH,
James
Simplicity Rules!
|
|
|
|
|
thanks.
but what is the meaning of "on minimize"?
does it have on-minimize event?
you said "set the windowstate of the main form to Restore",
does it mean that "this.WindowState=FormWindowState.Normal"?
thanks!
|
|
|
|
|
zhoujun wrote:
but what is the meaning of "on minimize"?
You can e.g play a sound when minimize the app or maximaze..
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Sorry, been working too close to Win32 lately. There isn't an on minimize event, but you can create one fairly easily by overriding WndProc.
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case 0x0112:
if( m.WParam.ToInt32() == 0xF020 )
{
}
base.WndProc(ref m);
break;
default:
base.WndProc(ref m);
}
}
zhoujun wrote:
you said "set the windowstate of the main form to Restore",
does it mean that "this.WindowState=FormWindowState.Normal"?
Oops, yes I did mean that
James
Simplicity Rules!
|
|
|
|
|
thanks James!
when i asked the question,i have not think of any methods that you proposed!
to my surprise,it has so many solutions.
maybe i should work hard!
thanks one more time!
|
|
|
|