FUNCTION Start( ) AS VOID
LOCAL x AS STRING
? x:= System.Environment.CommandLine
LOCAL Path AS STRING
? Path := System.IO.Path.GetDirectoryName( x)
Compiled as a X#-Runtime app, targetting X86 to enable debugging (crashs at runtime equally with "anycpu").
Running, crashes with "illegal charakter in path "C:\Dev\XIDE\Projects\4\Bin\Debug\XSharpRuntimeApp1.exe"
in the GetDirectory call.
Debugging, after setting a breakpoint at the ?Path line, shows that "x" is a empty string with length 1 (!)
It's because that System.Environment.CommandLine returns the command line used to execute the app, and in this case it is XIDE executing it and it always surrounds the executable with double quotes ("), in order to avoid problems with spaces. You may want to remove any such chars, before passing it to a File/Path method, or maybe you could use System.Environment.CurrentDirectory instead?
problem with Current is, that i can't be sure this to be what i "think" it is
Anyway, i already had tried a variant with
x := StrTrans(x, '"', ''), which didn't help - same error.
Initially i had touched some code, about 3 years old <g>:
FullName := System.Environment.CommandLine:Substring(1, System.Environment.CommandLine:IndexOf('"', 1) - 1)
which doesn't want to work anymore ("Out of range, Length can't be less than zero") - this did work all this time, until maybe a month ago it stopped. It's no important functionality, so i didn't bother then, but today i got in the mood...
EDIT: "Now", some hours later than my first report, nothing done with the app, i added the StrTran-Line another time - and now the crash is gone....
Returned to my main app, with the FullName code,
Seems, i'm going mad here, sorry..
Another half an hour later: the initial culprit, why my app's func didn't work anymore is found: the guy, who wrote FreeFileSync apparently changed the commandline params his tool expects.