How do I use OpenFileDialog to select a folder?

Basically you need the FolderBrowserDialog class: Prompts the user to select a folder. This class cannot be inherited. Example: using(var fbd = new FolderBrowserDialog()) { DialogResult result = fbd.ShowDialog(); if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) { string[] files = Directory.GetFiles(fbd.SelectedPath); System.Windows.Forms.MessageBox.Show(“Files found: ” + files.Length.ToString(), “Message”); } } If you work in WPF you have … Read more

URL Encoding using C#

I’ve been experimenting with the various methods .NET provide for URL encoding. Perhaps the following table will be useful (as output from a test app I wrote): Unencoded UrlEncoded UrlEncodedUnicode UrlPathEncoded EscapedDataString EscapedUriString HtmlEncoded HtmlAttributeEncoded HexEscaped A A A A A A A A %41 B B B B B B B B %42 a … Read more

What’s the difference between .NET Core, .NET Framework, and Xamarin?

You should use .NET Core, instead of .NET Framework or Xamarin, in the following 6 typical scenarios according to the documentation here. 1. Cross-Platform needs Clearly, if your goal is to have an application (web/service) that should be able to run across platforms (Windows, Linux and MacOS), the best choice in the .NET ecosystem is … Read more

How to get index using LINQ? [duplicate]

myCars.Select((v, i) => new {car = v, index = i}).First(myCondition).index; or the slightly shorter myCars.Select((car, index) => new {car, index}).First(myCondition).index; or the slightly shorter shorter myCars.Select((car, index) => (car, index)).First(myCondition).index;

How to get temporary folder for current user

System.IO.Path.GetTempPath() is just a wrapper for a native call to GetTempPath(..) in Kernel32. Have a look at http://msdn.microsoft.com/en-us/library/aa364992(VS.85).aspx Copied from that page: The GetTempPath function checks for the existence of environment variables in the following order and uses the first path found: The path specified by the TMP environment variable. The path specified by the … Read more

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