Home
Options

LINQPad prepending temp folder to path

edited March 2021

Hi there,

Whenever I am pasting a path, LINQPad will prepend a temp folder to it, like such:

C:\Users####\AppData\Local\Temp\LINQPad6_tasoozkv\shadow-1\‪C:\Users####\Pictures\______.jpg

The path pasted is C:\Users####\Pictures\______.jpg (edited for anonimity), the stuff before it gets added by LINQPad, how do I fix this?

I should carify, it doesn't do this when pasting, but when using the string.
for instance

var path = "C:\Users####\Documents\IISExpress\config\applicationhost.config";
File.ReadAllText(path); << Here it will be prepended

Thanks in advance!

Comments

  • Options

    It's unclear exactly what I need to do to create this condition.

    Could you provide a step-by-step repro?

  • Options
    edited March 2021

    Yes, of course! Thank you for the reply.

    1. Right click a file (I took a text file from my documents folder), click properties, go to the security tab and copy the path that's displayed in the top of the window
    2. Create a variable named path in LINQPad and paste the path you just copied. I made it a verbatim string. (You can also skip this step and paste the copied path directly as an argument to File.ReadAllText())
    3. On the next line put File.ReadAllText(path);
    4. Run the query

    Then I get this error:

    As you can see it will prepend a temp folder to the actual path I want to use.

    This started to happen to me after a clean install of Windows, did not happen before. It also happens in both LINQPad 5 and 6. I am running the fully unlocked version from the installer.

    Thank you for looking into this. Much appreciated! I use LINQPad daily and it has become one of my favorite tools to use! Also if there is anything else you need to know or want me to try let me know!

  • Options
    edited March 2021

    Can you run this example and show the output? Which version are you using?

    http://share.linqpad.net/qllpp8.linq

    (This example is based on v6.12.4 (X64) / v6.13.1 (X64) Beta)

  • Options

    Weird. There are a few more things you could check.
    What does path.Length.Dump(); say ?
    What does the IL show and in particular is it definitely calling System.IO.File.ReadAllText ?
    What does the stack trace say?

    What do you get for System.IO.Path.GetFullPath(path).Dump(); ?

    It would look like this is more a framework issue rather than a LinqPad issue, so can you try the same thing from VS.

  • Options

    Thank you both for replies!

    DISCLAIIMER: I ended up trying everything both of you suggested and lastly tried it in VS, seems like sgmoore was right and it is a framework issue, I will leave the rest of the post intact.If any of you maybe know how I should go about fixing this issue that would be appreciated, would a reinstall be enough?

    nescafe, I am using version 6.12.4(X64), and when I run the query I get this output:

    sgmoore, the path length that is dumped is correct, it shows the length without the extra folder prepended

    The IL shows this:

    And the stack trace:

    And lastly, System.IO.Path.GetFullPath(path).Dump(); does give me the path with the temp folder prepended.

    Thank you both for the help, I don't know why I didn't think of testing this in VS. :| At least now I know what direction to look into!

  • Options

    That's weird.. you could open ILSpy (F12 on GetFullPath method) to further dive in the PathHelper class (it ends in a kernel32.dll GetFullPathNameW call here).

  • Options

    Thank you for your reply, I will look into it and if that doesn't lead me anywhere I will probably do a clean install again to see if that will do it.

    Everyone who replied, thanks again!

  • Options

    Have you counted the characters exactly?

    You would get this error if the path starts with a space, but then a space would be obvious in the error message, but perhaps there is some other invisible character.

  • Options
    edited March 2021

    Wow! It does seem there is some kind of invisible character! When I type out the path manually its length is one less than the one that was copied from the security tab! Insane! Thank you for pointing me in this direction! The length I got was so different from what it had to be with the path prepended that I assumed it was correct.

    Seems like there is some kind of character prepended when I copy the path!

    Again, thank you for letting me double check! No idea how or why this happens but now at least I know about it!

    EDIT: appears it is a left-to-right embedding character according to this Microsoft post.

    Thank you very much sgmoore! I owe you one! Very weird as I'm sure this did not happen to me before and that post is from 2015 so it seems it has been around for a while!

Sign In or Register to comment.