However for the open file location phase, it doesn’t seem to respect the same syntax and literally tries to insert the /…/ into the data path. Here is my code:
As you can see, the /…/ no longer moves up by one directory, but is inserted literally into the path. Can anyone advise what the correct syntax is for the System.Diagnostic.Process.Start to navigate folders?
While I didn’t try it, I’m surprised that a “…/” within a path doesn’t back up a folder when used with Process.Start. Are you sure that’s true? Anyway, the following should construct a proper path without using the “…/” syntax:
// Get the parent path of the Application data path
string parentPath = Directory.GetParent(Application.dataPath);
// Add a "Screenshots" level to the path
string screenshotFilePath = Path.Combine(parentPath, "Screenshots");
I tried to use this code today as I ran into the same issue (code from original OP was working fine for launching an .exe but not for setting a string parameter), got all sorts of errors. Here they are some, the others derive from these two:
Cannot implicitly convert type System.IO.DirectoryInfo' to string’
Argument #1' cannot convert object’ expression to type `string’
I obviously didn’t test the above snippet. Looking, I see that Directory.GetParent returns a DirectoryInfo object (not a simple string). So, with that in mind, you need to get the “path” portion from the DirectoryInfo object. So, something like this (again, untested…):
// Get the parent path of the Application data path
DirectoryInfo di = Directory.GetParent(Application.dataPath);
string parentPath = di.FullName;
// Add a "Screenshots" level to the path
string screenshotFilePath = Path.Combine(parentPath, "Screenshots");
Ahh thanks for the quick answer Jeff - I was wondering how to convert that. Just got this working with your new code and moving it into the Start method. Much gratitude for the great suggestion, quick response and pleasant attitude!