Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning application on other machine doesn't work; C# application and Batch file interactions
    primarykey
    data
    text
    <p>I have a C# application and 3 batch files. When a file is opened with on of the batch files, what's supposed to happen is this:</p> <p>I get the path of the file that has been 'opened'; then I call another batch file that calls the application. The application reads the path, does all the stuff I want it to do (basically, a bit of parsing) and then writes the file back out to a new location, the path of which is set in one of the batch files.</p> <p>Here's some code - this is the batch file that a file is opened with initially:</p> <pre><code>@echo off set ROOT=%~dp0 set FILE=%1 set TMPBASE=%~n1 cd %ROOT% call otherBat.bat %FILE% %TMPBASE% </code></pre> <p>Then, otherBat is this:</p> <pre><code>@echo off set FILE=%FILE% set TMPBASE=%TMPBASE% call ConvNames.bat %FILE% %TMPBASE% %ROOT% call ConverterTool.exe </code></pre> <p>And finally, the bit where the new path is set:</p> <pre><code>@echo off set FILE=%FILE% set FILECSV=C:\ConverterTool\ConvertedFiles\%TMPBASE%CSV.csv echo %FILE% echo %FILECSV% </code></pre> <p>Here's some of the C# application where the paths are being read/written to:</p> <pre><code>Process process = new Process(); process.StartInfo.FileName = ("C:/ConverterTool/ConvNames.bat"); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.Start(); StreamReader sr = process.StandardOutput; String outputFile = sr.ReadToEnd(); String[] outFiles = outputFile.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); String filename = outFiles[0].Trim(remove); newFileName = outFiles[1]; FileStream file = File.Open(filename, FileMode.Open); StreamReader fileStreamRead = new StreamReader(file); fileStreamRead.Close(); //Stuff done using (FileStream fs = File.Open(newFileName, FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(); for (int i = 0; i &lt; fnames.Count; i++) { sw.WriteLine(stuffToWrite ); } } } </code></pre> <p>I'm pretty confident that my C# is fine. But I think there's something funky going on with the paths. It all works fine on my machine, but if I run it on another machine, it won't work - it doesn't crash, it just doesn't appear to do the conversion, UNLESS the file that I attempt to convert is in the same directory as my other files (I have a folder with the 3 batch files, the .exe and the folder in which to save the new file.)</p> <p>The second machine is set up exactly the same as the development machine; I did them both myself in the space of about two weeks. So I think it's in one of my bats that I'm doing something stupid - I'm new to writing batch files so I could easily be messing up something very basic. It's just strange that it acts as expected on one machine and not another (and I tested briefly on a third that it also didn't work on). </p> <p>If anyone spots where I might be going wrong, I'd appreciate being pointed in the right direction!</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload