Sign in to follow this  
Hawk

C# error Illegal characters in path.

Recommended Posts

Hi everyone,

I don't understand this error and I am looking for 1 hour straight to it. 

I decided to post this on C.to, please help me out!

Maybe @cups or @kekd know this but uhmm..

 

Exception:

 

System.ArgumentException

  HResult=0x80070057

  Message=Illegal characters in path.

  Source=mscorlib

  StackTrace:

   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)

   at System.IO.Path.GetFileName(String path)

   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)

   at Leaf.xNet.FileContent..ctor(String pathToContent, Int32 bufferSize)

   at Leaf.xNet.HttpRequest.Post(String address, String path)

   at VoorTestn.Program.Main(String[] args) in C:\Users\REMOVED\Desktop\alles\repos\VoorTestn\VoorTestn\Program.cs:line 50

 

 

 

Line of code:

string str = string.Concat(new string[]
       {
           "{\"email\":\"",
           naam,
           "\",\"password\":\"",
           wachtwoord,
           "\"}"
       });

Thanks!

PS:
naam and wachtwoord are strings. those are normal.

  • Like 1

Share this post


Link to post
Share on other sites

Your code will call System.IO.Path.CheckInvalidPathChars, which in turn checks for the the following:

 

double quote (")

 

left angle bracket (<)

 

right angle bracket (>)

 

veritical bar (|)

 

and for control characters less than 32 decimal (space).

 

make sure that these are not in your path

Share this post


Link to post
Share on other sites

Your code will call System.IO.Path.CheckInvalidPathChars, which in turn checks for the the following:

 

double quote (")

 

left angle bracket (<)

 

right angle bracket (>)

 

veritical bar (|)

 

and for control characters less than 32 decimal (space).

 

make sure that these are not in your path

 

I see some, how can I fix the double quotes ones? I have something like this: email:/"'

so e m a i l : /" "

Share this post


Link to post
Share on other sites

sir the path is the problem not your code

 

try this path

 

C:\\Users\REMOVED\Desktop\alles\repos\VoorTestn\VoorTestn\Program.cs:line 50

 

answers can come late since im at my university and learning

Share this post


Link to post
Share on other sites

I have the solution. You are making a call to xNet trying to post form data to an url. So what you did is xNet.HttpRequest.Post("www.test.com", postData);

 

Unfortunately, xNet thinks that you are trying to send the file located at the path [postData] (Look at the stack trace, the arguments are : Leaf.xNet.HttpRequest.Post(String address, String path)).

 

Therefore, to fix this you need to change the HttpRequest.Post("www.test.com", postData) to HttpRequest.Post("www.test.com", postData, "application/x-url-form-encoded");


Post Data is "str" in your code, it looks like JSON so you may need to change "application/x-url-form-encoded" to "application/json"

 

 

(string str = string.Concat(new string[]

{

"{\"email\":\"",

naam,

"\",\"password\":\"",

wachtwoord,

"\"}"

});

)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this