|
I have been able to launch a batch file from a C# program in a number of ways.
Duncan Mackenzie's blog on msdn shows a number of ways how it can be done and I have tried them. (http://blogs.msdn.com/csharpfaq/archive/2004/06/01/146375.aspx).
But I have a unique problem. The batch file launches a program that seems to require that a command window (cmd) be open when it runs. Because of this, the batch file works if I launch it from a command line, but when I launch it in a C# program, an exception is thrown.
So my question is this. How can I open a cmd window from C# and feed it the command to run the batch routine?
|
|
|
|
|
Use Process class to start new process. Specify cmd.exe as a program to run and pass the location of bat file as an argument. This should help.
BTW, what is the exception that you are getting?
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
When the compiler gives this warning, does the code actually compile? Is any MSIL generated for the code that is unreachable?
|
|
|
|
|
Use ILDasm on your assembly to find out.
Very nifty tool.
Scott
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
carbon_golem wrote: Use ILDasm on your assembly to find out.
Very nifty tool.
I second that.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Jasmine2501,
Try it out and see what happens, but why would you want something like this to be compiled? If you have code that is unreachable you might as well just hit the delete key on it.
Regards,
Gareth.
|
|
|
|
|
Yes exactly, but I'm interested in proving that it results in no-codez - because I'm hitting the delete key on someone else's stuff and they swear the compiler warning is just something to be ignored.
|
|
|
|
|
I believe it can be ignored as much as it warns you for unassigned variables etc, but if you want to modify someone else's code, how about commenting out segments you wish to change, or better yet just clone the project and play with it to your heart's content.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
Well I'm working in a company environment... anything I do has to integrate with everything else. This is a super-large project. It takes Visual Studio literally 5 minutes to compile the site and all the DLLs and everything. I'm optimizing things, and I do have free reign on the code at the moment, but I do have to justify what I do sometimes.
I realize that the warnings don't prevent the thing from working, but they are not be ignored. One of my mentors always said "warnings are like a sign saying the bridge is out - it won't keep you from going down the road, but there's gonna be trouble eventually"
|
|
|
|
|
Hi,
I use #if false and #endif for hiding code.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Yes and no.
A switch statement with a return immediately before a break. The break is unreachable so is not compiled into IL.
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
No, there isn't - which I'm a bit surprised about. Makes no sense to include unreachable code I guess. Confirmed via Reflector/ildasm.
Regards,
Rob Philpott.
|
|
|
|
|
Just be sure it's not the result of conditional compilation. Though even then it should be written so as not to produce a warning.
|
|
|
|
|
Yes, our site originally had over 100 compiler warnings when you build. I consider that a Bad Thing. I've got it down to 23 at the moment, but I want to get it down to zero. Warnings are the computer telling you that something stupid is going on, not a broken something stupid, but still something stupid, and in most cases you just delete the thing, or code it a different way and it's functionally equivalent, but doesn't cause the warning. The break after a return statement is a good example... not having the break eliminates the warning, the break isn't necessary, and it's probably just there because somebody was told to put breaks in their switch/case blocks and was never told what it actually does.
|
|
|
|
|
Good Afternoon
I have been using vb.net am i recently moved to C# and thanks to codeProject am comming alright. now in vb.net we had Events ready generated for us on controls like button, when you double click on the button, on the right hand side you could select the events like "keypress", but vs on C# does nto have that.How is it done in C#, do i have to code the events myself?
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Not at all. Click the control in the designer to select it, press F4 (usually) for properties. Find the little lightning strike button, this shows you all the events on the control. Double click next to one to automatically insert the handler.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks man
it works
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
You can double click on a control, like a button, and the default event, Click in this case, will be automatically created for you.
only two letters away from being an asset
|
|
|
|
|
Thank you very much
it works
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Say, I have 1000 different coordinate points which are totally scattered. Please give me some suggestions regarding how to find out the outer envelope area of those plotted points. Please provide me any link or sample project. Any suggestion on the algorithm would be helpful too.
Thanks in advance...
Faysal
|
|
|
|
|
Interesting problem. When you talk about the outer envelope - is this the smallest shape that contains all the points?
And when you say area - do you mean area (as measured in square centimetres say) or just the subset of points which define it?
Regards,
Rob Philpott.
|
|
|
|
|
|
Sorry, how is it related to the envelope area?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Because the envelope would be the shape bounded by the leaves of the tree.
|
|
|
|