i wrote some program in c++ that open csv file and do somthing and copy the resault to new CSV file
after compile i get exe file. when i run the exe file, its working well (create the new CSV file)

but if i try to run the exe file from c# with press on button its not working
i saw the conolse(black windows open and close) but not create the new CSV file

that what i using:
using System.Diagnostics;
Process.Start(@"C:\project\DataTreatment\DataTreatment\DataTreatment.exe");

can some help

Is the csv file in the same folder as the *.exe you are trying to run? If not then you need to tell the *.exe program where to find the folder. You might have to make a slight change to the c++ program then recompile, for example you could allow for a command-line argument that has the full path to the csv file.

yes the CSV files is in the same folder.
when i do doble click on exe file its working well when i try to do it from C# not working

Process.Start(@"C:\project\DataTreatment\DataTreatment\DataTreatment.exe");

What's that @ symbol doing there? Is that just a typo or is that really in your program? Also the \ needs to be \\, like this (There needs to be 4 of them in order for 2 to show up in this editor)

Process.Start("C:\\project\\DataTreatment\\DataTreatment\\DataTreatment.exe");

Can you reproduce the problem with a very small C# program that does nothing have that line in main()?

What AD is trying to say is, if your host app is running in a different directory to your target app, you will need to tell it the correct directory. For example:

My C# app is here - C:\MyProjects\CSharp\CSharpHost.exe
My C++ app is here - C:\MyProjects\CPP\ProcessCSV.exe
My CSV is here - C:\MyProjects\CPP\MyFile.csv

In C# I perform the following:
Process.Start("C:\MyProjects\CPP\ProcessCSV.exe");

Your Current Working Directory is C:\MyProjects\CSharp and so if you simply look in the root folder in yoru C++ app, it will look at the following location: C:\MyProjects\CSharp\MyFile.csv

You need to create a ProcessStartInfo object and set the correct working directory on that.

Ancient Dragon, the @ translates to literal so that you don't have to escape all escape characters. In other words:

"this is a line\r\l this is a new line" will print:

this is a line
this is a new line

while @"this is a line\r\l this is a new line" will print:

this is a line\r\l this is a new line

if i take the CSV file and EXE file to any directory on my computer its work.

so you mean i need to take the 2 files and locate them in c# directory?

Ketsuekiame i move it to C# folder and its works

Thanks a Lot

You could change the c++ program to recognize command-line parameter so that the csv file could be located anywhere.

yes i will do it thanks a lot for help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.