I have the following code for converting xml to csv by using perl script. When I run the perl script through c# but there is no files are created and string output become empty. What is the problem? I have the perl script with .txt extention, Is this ok or not?
string filePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + "/Files/SAVVIS_CDR_1806012231.XML";
if (Path.GetExtension(filePath) != "csv")
{
ProcessStartInfo perlStartInfo = new ProcessStartInfo(@"C:\Strawberry\perl\bin\perl.exe");
string perlScriptFilePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + "/PerlScript/formatter_savvis.pl.txt";
string csvFilePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + "/PerlScript/";
perlStartInfo.Arguments = perlScriptFilePath + " " + filePath + " " + csvFilePath;
perlStartInfo.UseShellExecute = false;
perlStartInfo.RedirectStandardOutput = true;
perlStartInfo.RedirectStandardError = true;
perlStartInfo.CreateNoWindow = false;
Process perl = new Process();
perl.StartInfo = perlStartInfo;
perl.Start();
perl.WaitForExit();
string output = perl.StandardOutput.ReadToEnd();
}
Could you please anyone help me to solve this problem? Thanks in advance.
perltag, but to be fair, I also added thec#tag. OP doesn't seem to know what's going on or what their question actually is.perl.WaitForExit();andperl.StandardOutput.ReadToEnd();-- see this answer to Running Perl throughC# code for details. But beyond that we need to see a minimal reproducible example, you do a lot of manipulation of files paths and such, are you sure directories and files actually exist at the stated location(s)? Try callingFile.Exists(string)andDirectory.Exists(string)in the debugger to be sure.