I have python script having input command i.e taking input(directory) from user. Using PyInstaller I have generated exe of that script. Now I want to consume this exe from C# by giving input parameter. But Somehow even after giving arguments from C# it is not taking and pops up Python exe command prompt.
Python Code:
def CreateCSVFile(CSVDirectory):
try:
file_path = os.path.join(CSVDirectory, 'ExportResult_Stamp.csv')
## delete only if file exists ##
if os.path.exists(file_path):
os.remove(file_path)
# Create column names as required
row = ['FileName', 'Document123','abc','xyz','zzz']
with open(file_path, 'w+') as csvFile:
writer = csv.writer(csvFile)
writer.writerow(row)
csvFile.close()
except Exception as e:
print(str("Exception occurs:"+ e))
strDocDir = input("Give document directory:")
#print(strDocDir)
if os.path.exists(os.path.dirname(strDocDir)):
CreateCSVFile(strDocDir)
else:
warnings.warn("Provided directory doesn't exist:" + strDocDir)
C# Code:
string strCurrentPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
ProcessStartInfo startInfo = new ProcessStartInfo(string.Concat(strCurrentPath, "\\Test\\", "CSV.exe"));
startInfo.Arguments = @"C:\Pankaj\Office\ML\Projects\Stampdocuments\DDR041";
startInfo.UseShellExecute = true;
var process = System.Diagnostics.Process.Start(startInfo);
process.WaitForExit();
Please suggest.
from Run python Script(having input()) exe form C#
No comments:
Post a Comment