fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Illegal char?

Illegal char? 6 days 15 hours ago #1

  FFF's Avatar Topic Author FFF Offline Posts: 532
Folks,
FUNCTION Start( ) AS VOID
LOCAL x AS STRING
? x:= System.Environment.CommandLine
LOCAL Path AS STRING
? Path := System.IO.Path.GetDirectoryName( x)
RETURN
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 (!)

Anyone an idea?
Karl

Please Log in or Create an account to join the conversation.

Last edit: by FFF.

Illegal char? 6 days 15 hours ago #2

  Terry's Avatar Terry Offline Posts: 122
A total and utter guess - could a space have found it's way into x ?

Terry

Please Log in or Create an account to join the conversation.

Illegal char? 6 days 14 hours ago #3

  Chris's Avatar Chris Offline Posts: 1056
Hi Karl,

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?
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

Illegal char? 6 days 12 hours ago #4

  FFF's Avatar Topic Author FFF Offline Posts: 532
Chris,
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.
Grrrrr....

Karl

Please Log in or Create an account to join the conversation.

Illegal char? 4 days 12 hours ago #5

  Terry's Avatar Terry Offline Posts: 122
Karl

If I've understood things correctly trimming x before submitting to GetDirectoryName(x) maybe worth a try.

Terry

Please Log in or Create an account to join the conversation.

  • Page:
  • 1