How can one get an absolute or normalized file path in .NET?

I would write it like this: public static string NormalizePath(string path) { return Path.GetFullPath(new Uri(path).LocalPath) .TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) .ToUpperInvariant(); } This should handle few scenarios like uri and potential escaped characters in it, like file:///C:/Test%20Project.exe -> C:\TEST PROJECT.EXE path segments specified by dots to denote current or parent directory c:\aaa\bbb\..\ccc -> C:\AAA\CCC tilde shortened (long) paths … Read more

Convert content:// URI to actual path in Android 4.4

This will get the file path from the MediaProvider, DownloadsProvider, and ExternalStorageProvider, while falling back to the unofficial ContentProvider method you mention. /** * Get a file path from a Uri. This will get the the path for Storage Access * Framework Documents, as well as the _data field for the MediaStore and * other … Read more

Getting filesystem path of class being executed [duplicate]

The following code snippet will do this for you: final File f = new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath()); replace MyClass with your main class The resulting File object f represents the .jar file that was executed. You can use this object to get the parent to find the directory that the .jar is in.

How to get execution directory of console application

Use Environment.CurrentDirectory. Gets or sets the fully qualified path of the current working directory. (MSDN Environment.CurrentDirectory Property) string logsDirectory = Path.Combine(Environment.CurrentDirectory, “logs”); If your application is running in c:\Foo\Bar logsDirectory will point to c:\Foo\Bar\logs.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)