Essentially, this is the problem I'm facing
Path.GetFullPath("~/Documents/Temp");
It searches for the the path "~/Documents/Temp" relative to my project folder; but I actually need is the ~/Documents/Temp from the root not from the project path.
This is because I don't want to store all uploaded files in a folder underneath my project folder but in another folder ("possible in another drive or a Network Path").
How is it possible to do this because I'm not getting the actual path no matter what I tried. Thanks!
~ is a character recognized to have special meaning by some shells, such that the shell expands ~ to mean the current user's home directory, but it's a valid file name character like any other as far as the file system is concerned, and Path doesn't confer to it any special meaning (as is the case with other language's utilities, like C, Go, etc.). Note that even in a shell such as bash you can run commands like:
cd ~
mkdir "~"
cd "~"
That will change you into your home directory, but then create a directory named ~ in your home directory and cd into that, with the quotes escaping the specialness.
As Stephen mentioned, this is a shell related thing. You can get the folder from Environment.GetFolderPath(SpecialFolder.UserProfile) and use that to build your paths via Path.Combine().
Most helpful comment
~is a character recognized to have special meaning by some shells, such that the shell expands ~ to mean the current user's home directory, but it's a valid file name character like any other as far as the file system is concerned, andPathdoesn't confer to it any special meaning (as is the case with other language's utilities, like C, Go, etc.). Note that even in a shell such as bash you can run commands like:That will change you into your home directory, but then create a directory named ~ in your home directory and cd into that, with the quotes escaping the specialness.