Getting the absolute path of the executable, using C#?

MSDN has an article that says to use System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; if you need the directory, use System.IO.Path.GetDirectoryName on that result. Or, there’s the shorter Application.ExecutablePath which “Gets the path for the executable file that started the application, including the executable name” so that might mean it’s slightly less reliable depending on how the application was launched.

How to get folder directory from HTML input type “file” or any other way?

Stumbled on this page as well, and then found out this is possible with just javascript (no plugins like ActiveX or Flash) Basically, they added support for a new attribute on the file input element “webkitdirectory”. You can use it like this: <input type=”file” id=”ctrl” webkitdirectory directory multiple/> It allows you to select directories. The … Read more

Android: How to open a specific folder via Intent and show its content in a file browser?

This should help you: Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory() + “/myFolder/”); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(selectedUri, “resource/folder”); if (intent.resolveActivityInfo(getPackageManager(), 0) != null) { startActivity(intent); } else { // if you reach this place, it means there is no any file // explorer app installed on your device } Please, be sure that you have any … Read more

Checking for directory and file write permissions in .NET

Directory.GetAccessControl(path) does what you are asking for. public static bool HasWritePermissionOnDir(string path) { var writeAllow = false; var writeDeny = false; var accessControlList = Directory.GetAccessControl(path); if (accessControlList == null) return false; var accessRules = accessControlList.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier)); if (accessRules ==null) return false; foreach (FileSystemAccessRule rule in accessRules) { if ((FileSystemRights.Write & rule.FileSystemRights) != FileSystemRights.Write) continue; … Read more

How to find the real user home directory using python?

I think os.path.expanduser(path) could be helpful. On Unix and Windows, return the argument with an initial component of ~ or ~user replaced by that user‘s home directory. On Unix, an initial ~ is replaced by the environment variable HOME if it is set; otherwise the current user’s home directory is looked up in the password … Read more

How to check if a directory/file/symlink exists with one command in Ruby

The standard File module has the usual file tests available: RUBY_VERSION # => “1.9.2” bashrc = ENV[‘HOME’] + ‘/.bashrc’ File.exist?(bashrc) # => true File.file?(bashrc) # => true File.directory?(bashrc) # => false You should be able to find what you want there. OP: “Thanks but I need all three true or false” Obviously not. Ok, try … Read more

Can a Ruby script tell what directory it’s in?

For newer versions of Ruby, try: __dir__ For older versions of Ruby (< 2.0), the script being run can be found using: File.dirname(__FILE__) – relative path; or File.expand_path(File.dirname(__FILE__)) – the absolute path. Note: Using __dir__ will return the script path even after a call to Dir.chdir; whereas, using the older syntax may not return the … Read more

Get Application Directory

There is a simpler way to get the application data directory with min API 4+. From any Context (e.g. Activity, Application): getApplicationInfo().dataDir http://developer.android.com/reference/android/content/Context.html#getApplicationInfo()

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