|
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!
|
|
|
|
|
Check the NotifyIcon class in .NET, works nice.
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
zhoujun wrote:
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!
Another way to check for Minimize is to override the OnResize and check your window state:
protected override void OnResize(System.EventArgs e)
{
if(WindowState==FormWindowState.Minimized)
{
ShowInTaskbar = false;
}
}
Be sure to save off you window placement and size first though. Then all you need to do is override the notification icon Click event and enable your window again.
Rocky Moore
|
|
|
|
|
Geez, any one have a brick wall handy? My head needs to run into it a few times, maybe it'll think of the obvious solution next time
Thanks for the reminder
James
Simplicity Rules!
|
|
|
|
|
thanks Rocky!
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!
|
|
|
|
|
Have this been here before!?
Well, I have two string objects.
string name = "Bob is cool";
string myString = "Hello every body, my name is Bob, and bob is cool";
How to find name in myString??
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
int pos = myString.IndexOf(name);
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Is it really the right way!?
well.... okay then..!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
hello,
when the below line runs it creates the dll in the application's bin\Debug directory. i'm trying to write it to a directory of my choice instead. i posted this last week. did anyone come across how i might do this. i'll post more code if you need it but the example that's basically the same thing i'm doing is at.
http://www.codeproject.com/csharp/cscompiler.asp
compilerResults = codeCompiler.CompileAssemblyFromSource(compilerParamaters, sourceWSProxy);
i've played around with some of the Parameter properties and couldn't get it to work. so maybe i'm just not doing it right. CompilerResults has a PathToAssembly property but that's after the fact.
any help is appreciated. By the way Tom, if you read this good book on C#. we've got 2 copies of it in our office.
thanks
Orion
|
|
|
|
|
i've tried a couple of things but still doesn't work. or maybe i'm doing something wrong.
i can get it to write to some directory but then the file(dll) that i'm creating loses its COM component qualities. so its no longer considered a dll, although it still has the extension. at least that's the error i get when i go to Add Reference to the newly created dll. i'm attempting to pass the path in as part of the OutputAssembly CompilerParameter.
compilerParamaters.OutputAssembly = File.CreateText(@"C:\WUTemp\" + fileNameAssembly).ToString();
the other thing i've tried is to create it InMemory and then try to write to some directory. this produces the same result. the file is created with the dll extension but its missing the components.
any thoughts??
thanks
Orion
|
|
|
|
|
Shouldn't that be, compilerParamaters.OutputAssembly = @"C:\WUTemp\" + fileNameAssembly ?
James
Simplicity Rules!
|
|
|
|
|
James,
Thanks! that works. Yes Simplicity rules yet again. now i feel like a dumb ass,, but i don't care it works ;~))
Orion
|
|
|
|