473,372 Members | 819 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,372 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 2382
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 N2 (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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.