0

I've recently written a Console application in C# which is meant to work across OSX, Linux and Windows. Part of the application provides a bash style path auto completion (ie, where you can press tab and it does the work for you...).

It all works pretty nicely, however if the user was to enter ~/ and then press TAB, it does not understand that ~/ means the home directory.

I'm just wondering what the general opinion is of the nicest way to handle ~/ and convert it to the home directory? I've tried Path.GetFullPath() but it doesn't seem to work.

Btw I'm testing all this on OSX currently.

Edit: This is not a duplicate of the marked question, getting the home directory is easy. My question is, if someone enters a path with ~/ in it, is there some method i can feed it into that sanitises the path and removes the ~/ and possibly any other platform specific shortcuts like that.

JimCricket
  • 51
  • 1
  • 6
  • 1
    You may need to add code to listen for when ~/ is entered and then use environmental variables to locate and translate it to the home directory. How are you currently doing your auto-complete? – JNYRanger Jan 14 '14 at 21:03
  • 3
    Please show your code. – tnw Jan 14 '14 at 21:03
  • It is still a duplicate of the one above. Just replace `~/` with its absolute path and append the rest of the string. – Mike Jan 14 '14 at 22:44
  • No offence Mike, thats the obvious solution. I didn't come onto stack overflow and ask the question for the obvious solution (i probably should have stated that). I want some sort of way to nicely handle native path shortcuts basically. For all i know, there may be other valid shortcuts like ~/ that exist which I'm not handling... – JimCricket Jan 15 '14 at 22:01

0 Answers0