You could use a normal string literal, but you'd have to escape the the quotes with \"
and backslashes with \\
, like this:
var str = "run(\"'Bio-Formats Importer'\",\"'open=[D:\\\\fiji\\\\ChanA_0001_0001_0001_0001.tif] display_ome-xml'\")";
Or by using a verbatim string literal, but you need to escape the quotes with ""
, like this:
var str = @"run(""'Bio-Formats Importer'"",""'open=[D:\\fiji\\ChanA_0001_0001_0001_0001.tif] display_ome-xml'"")";
Further Reading
Regarding your update, it seems like the problem is that you need to double the slashes in the file path for the benefit of the command line string. I would also recommend simplifying it to something like this:
using System.IO;
using System.Diagnostics;
var filesList = Directory.GetFiles(folder, "*.tif");
var bioformats = "Bio-Formats Importer";
foreach(var fileName in filesList) // loop through every file
{
var options = string.Format("open=[{0}] display_ome-xml", fileName.Replace("\\", "\\\\"));
var args = string.Format("-eval run(\"'{0}'\",\"'{1}'\")", bioformats, options);
try
{
var process = new Process
{
StartInfo = new ProcessStartInfo
{
WindowStyle = ProcessWindowStyle.Hidden,
FileName = fijiExeFile,
Arguments = args,
}
};
process.Start();
process.WaitForExit();
ret = 1;
}
catch (Exception ex)
{
ex.ToString();
ret = 0;
}
}