473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

weird OpenFileDialog Problem with cmd.exe

Hello everyone,

I have a C# program that runs a batch from the command line.
I use the following code for that:

String arguments = "/C CALL batchfile.bat";
ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe");
startInfo.Arguments = arguments;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
Process p = Process.Start(startInfo);
string output = p.StandardOutput.ReadToEnd();
string error = p.StandardError.ReadToEnd();
p.WaitForExit();

This works just fine.

But as soon as I use a OpenFilerDialog in my Program the batch won't
work any more.

OpenFileDialog fileDlg = new OpenFileDialog();
fileDlg .Filter = "PDF|*.pdf|Word|*.doc|All|*.*" ;
fileDlg .FilterIndex = 1 ;
if(fileDlg .ShowDialog() == DialogResult.OK)
{
Stream myStream = null;
if((myStream = fileDlg .OpenFile()) != null)
{
...
myStream.Close();
}
}

Any ideas?
Thanks in advance.

Greetings juergen

Feb 13 '06 #1
4 2383
HI,

();

This works just fine.

But as soon as I use a OpenFilerDialog in my Program the batch won't
work any more.


I fail to see the connection between the 2 code snipes , are they in the
same method?

Do you get any exception at all?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 13 '06 #2
What happens?
Nothing happens?
You know that you can't have modal dialogs in a batch application, don't
you? What do you expect to happen?
The process will be halt on the ShowDialog until an user interacts with your
app...

<bb*******@lycos.de> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hello everyone,

I have a C# program that runs a batch from the command line.
I use the following code for that:

String arguments = "/C CALL batchfile.bat";
ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe");
startInfo.Arguments = arguments;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
Process p = Process.Start(startInfo);
string output = p.StandardOutput.ReadToEnd();
string error = p.StandardError.ReadToEnd();
p.WaitForExit();

This works just fine.

But as soon as I use a OpenFilerDialog in my Program the batch won't
work any more.

OpenFileDialog fileDlg = new OpenFileDialog();
fileDlg .Filter = "PDF|*.pdf|Word|*.doc|All|*.*" ;
fileDlg .FilterIndex = 1 ;
if(fileDlg .ShowDialog() == DialogResult.OK)
{
Stream myStream = null;
if((myStream = fileDlg .OpenFile()) != null)
{
...
myStream.Close();
}
}

Any ideas?
Thanks in advance.

Greetings juergen

Feb 13 '06 #3
Hi again,

I have a application that does many things. One of them is to execute a
batch in command shell.

And the weird things is that the 2 code snips are not connected.

I choose a file in the openfiledialog and do other things.
then i click start (in my app) and the batch runs.

but it only runs if i didn't use the openfiledialog.
if i use the openfiledialog the commands in the batch won't be
executed.
the command process just returns at once just s if i have a empty batch
file.

funny, isn't it?

greetings juergen

Feb 14 '06 #4
Weird...
Are you sure that there's nothing more that is made when you use
OpenFileDialog?
<bb*******@lycos.de> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi again,

I have a application that does many things. One of them is to execute a
batch in command shell.

And the weird things is that the 2 code snips are not connected.

I choose a file in the openfiledialog and do other things.
then i click start (in my app) and the batch runs.

but it only runs if i didn't use the openfiledialog.
if i use the openfiledialog the commands in the batch won't be
executed.
the command process just returns at once just s if i have a empty batch
file.

funny, isn't it?

greetings juergen

Feb 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matthieu Tudury | last post by:
Hi, i got a weird problem with decimal numbers, Here is a test sample : float a, b, c; double da, db, dc; da = 313.83; db = 262.4; dc = db -da;
1
by: Chris Mantoulidis | last post by:
PROBLEM: I'm having some weird problems with string::find() (in ParamGenerate()), but since I'm not sure if that is the source of all bad output in my program, I'm posting least code that's...
2
by: M. Simioni | last post by:
Hi, the webserver is a HP ProLiant DL380 G3 1GB RAM Dual U320 SCSI COMPAQ Smart Array 5i + Battery Pack installed N°2 (RAID 1) COMPAQ BD072863B2 - 72.8GB Ultra320, 10K Hot-pluggable, 1"...
1
by: Dees | last post by:
Hi, I am facing a weird problem with HTTPS and Request.Url.AbsoluteUri in my ASP.NET application. Here is the scenario - 1. I have a menu page (Default.aspx), which has the following anchor -...
2
by: Bill Nguyen | last post by:
Every time I jumped to a new month, the app kept popping up the message box for subsequent months until 2050! If I stayed within the same month (current month), it worked fine. Please take a look...
0
by: piesse | last post by:
I am experiencing a weird problem with a popular PHP web application (Moodle). The thing uses a custom function to allow you to download/open a file. That function just send a series of header...
6
by: jsamdirect | last post by:
I am having a weird issue with php preg_match. I am moving to my php sites to a new server. On the old server all works well. On the new server preg_match always returns false. If I log in via ssh...
9
by: mrstevegross | last post by:
I ran into a weird behavior with lexical scope in Python. I'm hoping someone on this forum can explain it to me. Here's the situation: I have an Outer class. In the Outer class, I define a...
1
antonopn
by: antonopn | last post by:
Hello there, I have just faced a really weird problem with a query in SQL SERVER 2000. I had a database with collation SQL_Latin1_General_CP1_CI_AS and converted it in a new database with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.