Thursday, 16 October 2014

Windows Phone - Load Images from Web Url

You can load an image from the internet and display in your Silverlight Windows Phone Application.
The C# code is:
Uri uri = new Uri("http://Habeeb.in/pic.jpg", UriKind.Absolute)
image1.Source = new BitmapImage(uri);
Happy coding....

Tuesday, 30 September 2014

SQL Server - Group DateTime by Minutes / x minutes

If you want to group by records based on Minutes use the below Group By:
GROUP BY
DATEPART(YEAR, SUB.[SubOnDate]),
DATEPART(MONTH, SUB.[SubOnDate]),
DATEPART(DAY, SUB.[SubOnDate]),
DATEPART(HOUR, SUB.[SubOnDate]),
DATEPART(MINUTE, SUB.[SubOnDate])

If you want to group by records by x minutes, it is as below. In the sample below its grouped by every 10 minutes. so records within each 10 minutes will be in the same group.
GROUP BY
DATEPART(YEAR, SUB.[SubOnDate]),
DATEPART(MONTH, SUB.[SubOnDate]),
DATEPART(DAY, SUB.[SubOnDate]),
DATEPART(HOUR, SUB.[SubOnDate]),
(DATEPART(MINUTE, SUB.[SubOnDate]) / 10)

Monday, 22 September 2014

How to generate web service from wsdl file

This is a common scenario faced by developers who do web service based integrations. The partner if its an external company, might send over the wsdl file and ask to create a web service out of it so they can consume your webservice.

This is when the partner demands more control and they want to make sure all their partners host similar webservices so that the partner's code for the web service call is consistent.

Now to solve the matter, we do not have a GUI genie (wizard) for our help. We will have to do each step manually taking help of command line.

Here are the steps:
1) From the WSDL file create an Interface class using wsdl tool. For this, bring up the Visual Studio Command Prompt Window and run the below command.
wsdl.exe yourFile.wsdl /l:CS /serverInterface
Note: You can decide the language of the Interface Class generated. In parameter /l, use VB or CS for your Visual Basic or CSharp respectively. Finally the command will create a new .cs or .vb file.

2) Create a new .NET Web Service (.asmx).

3) Import the file created in the above step into your project.

4) In your .asmx.cs file in Code-View, modify class as below to implement the interface generated in the above step:
public class MyWebService : System.Web.Services.WebService, IWsdlService
{
// Web methods and other calls goes here....
}
5) Implement the methods mentioned in the Interface class. Finally your webservice class will be something like this:
public class MyWebService : System.Web.Services.WebService, IWsdlService
{
[WebMethod]
public string MyWeMethod1()
{
// your business logic goes here...
return "MyWeMethod1 Result";
}
[WebMethod]
public string MyWeMethod2()
{
// your business logic goes here...
return "MyWeMethod2 Result";
}

Tuesday, 16 September 2014

Javascript - How to check if a string contains another string

String function indexOf returns the position of the sub string in a string. If it doesn't find an occurance of the sub string, it will return -1.
var mainText = "microsoft";
var isSubstring = mainText.indexOf("soft") > -1
alert(isSubstring);
In the example, it checks for the substring "soft" within the main string "microsoft". As it find "soft" inside "microsoft", mainText.indexOf("soft") evaluates to 5 and isSubstring will be true;

Wednesday, 10 September 2014

Data transfer speed between devices

Data transfer speed depends on many factors including the devices involved and the medium transferring data.

BUS
Bus is the actual wires that carry data. There are different types of bus (eg: Universal Serial Bus (USB), Ethernet) and they follow different protocols. Different controller chips (Integrated Circuits (IC)) take care of these protocols for data transfer. Now, each system will have its own controllers which vary in their capabilities and configurations. The working of these controllers affect the data transfer speeds. Some cheaper systems will rely on CPU for data transfer while more expensive ones will have dedicated controllers for data transfer. Systems using CPU cycles for data transfer slow down the system's performance as well as the data transfer speeds. Now a days, most systems have its own usb controller chips which will not steal CPU cycles and thus improving data transfer rate between devices. But system might have 3 usb ports and each one might have devices like mouse and external hard disks connected. All these devices and sometimes even your internal hard disk might share the same bus (wires) internally. In which case, each time you move the mouse, it interrupts the communication to your hard disks, making the data transfer rates to the disk slower.

Another factor related to buses is DMI (direct memory interface). It is an option which the controllers can use to make transfer rate appear better. Here controllers are allowed to use a portion of RAM as a buffer/cache data before actually writing to the disk. Typically this memory allocation is in the range of 16MB to 64MB. So if your data to be transferred is within this range, it showes to complete fast and if the dataoverflows this DMI memory, then it will fall back to the speed of the device. When a hard disk advertizes its transfer speed to be 480mb/s, the speed is available only for files within the size of the buffer. Once the buffer is full, the transfer rate falls down to the actual speed of the disk.

HARD DISK
I am specifically talking about the Mechanical HDD (Hard Disk Drive) and not the new SSD. Hard disk is the part of a computer that stays as a bottle neck for the performace of the rest of the components like Processor, RAM and the Bus. It is the only mechanical component in a computer and this explains for the low performance. HDD has Magnetic disks on which data is stored. It also has a disk arm/head which move around the disk platter to read/write data. This is a time consuming activity as the the disk arm / head has to physically move around. Obviously read operations are much faster than writes as writes also involve finding the place to insert/update data and changing the data on disk. Another factor is the fragmentation of data on the disk. The more fragmented a file is, the more the data is spread out on the disk and the longer it takes for the mechanical arm to move around and read or write data. Another factor affecting the transfer rate is the buffer memory of the disk. For example bus speed of ESATA is 3GB/sec. So while the disk buffer of say 64MB fills up at 3GB/sec, then it falls back to the disk speed of say 15bm/sec - 30mb/sec.

FILE SYSTEM
Different Operating Systems use different File Systems. Windows use NTFS/FAT32 and Linux use ext1/ext2/ext3/ext4. File System work on mapping the physical locations of file into human readable file names. It is more complicated than said because fragmentation is handled differently by different file systems and they efficiency to manage fragmentation varies with file systems. The more fragmented your disk is the more time it takes to fetch a complete file. Studies have shown that Linux ext3/4 deals more efficiently with defragmentation.
Also if your physical drive has multiple partitions and you move data from one partition to the other, it will be ridiculously slow. It is because the same disk arm has to move to a location to read data and move to the other location to write it. So moving files between partitions would be slower.

Saturday, 6 September 2014

MAC OS- How to view Next and Previous photos from Finder

Image preview works a little different than from Windows Preview.
In WINDOWS you open an image from Windows Explorer and the Photo opens up in Windows Preview by default. You can view the next or previous images by clicking the left or right arrows.

In MAC OS, its a bit different, but gives you even a better experience sometimes.
Follow the below steps:
  1. From FINDER go to Photos folder, CMD+A (select all)
    • You can also select only some images according to your choice of viewing.
  2. Once selected, CMD+O (open)
  3. This will open the Photos in PREWIEW application
  4. View the next or previous photo with Right Arrow or Left Arrow. (Also Up / Down Arrow works. The trackpad slide works as well)
CMD+A (Select All)

CMD+O (Opens the selected Images in PREVIEW)

SQL SERVER 2008 - You must use the Role Management Tool to install or configure Microsoft .NET Framework 3.5.

While trying to install Visual Studio 2008 / SQL Server Management Studio or SQL Server Connectivity Tools on a Windows 2008 R2 machine you may get the following error.

You must use the Role Management Tool to install or configure Microsoft .NET Framework 3.5.

If you try to download .NET Framework 3.5 and install also it will give you error.

This is because Windows 2008 R2 already ships with the .NET 3.5.1 framework which needs to be enabled. You can enable the feature from Server Manager.

Steps:
1) Go To "Server Manager Console Window".
2) In the Console tree on the left, click Features.
3) In the Features pane click Add Features.
4) In the Add Features Wizard, select ".NET Framework 3.5.1 Features" and click Install.

Once you install the .NET Framework 3.5.1 Features from the Add Features Wizard in Server Manager, you can try installing VS 2008 / SSMS.

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.


start-> Run--> c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -iru

To resolve this issue, run the following command line:
aspnet_regiis.exe /iru
The Aspnet_regiis.exe file can be found in one of the following locations:
%windir%\Microsoft.NET\Framework\v4.0.30319
%windir%\Microsoft.NET\Framework64\v4.0.30319 (on a 64-bit computer)

Monday, 25 August 2014

C# - Evaluating Math Expressions at Runtime

There are third party Mathematical Expressions Evaluator libraries like NCalc (http://ncalc.codeplex.com/) which help you evaluate math expressions at runtime. But if your requirements are simple and do not want to get into the hazzles of third party references, you can make use of a hidden expression evaluator within .NET library.

It is Compute method within DataTable object that come to our help. Note that its not a static method and thus you have to use and instance of DataTable class.

using System.Data;
DataTable dt = new DataTable();
var result = dt.Compute("5*(4-2)","");
Console.WriteLine(result.ToString());

Happy Coding....

Thursday, 3 July 2014

SQL - Find Duplicate Rows based on multiple Columns

If you want to find duplicate rows based on some specific rows, you can do it easily in SQL Server Partition and Row_Number function. Below are the code snippets:

Results with Duplicates eliminated.
;WITH x AS
(
SELECT col1, col2, col3, rn = ROW_NUMBER() OVER
(PARTITION BY col1, col2, col3 ORDER BY id)
FROM dbo.tbl
)
SELECT col1, col2, col3 FROM x WHERE rn = 1;
Duplicate rows
;WITH x AS
(
SELECT col1, col2, col3, rn = ROW_NUMBER() OVER
(PARTITION BY col1, col2, col3 ORDER BY id)
FROM dbo.tbl
)
SELECT col1, col2, col3 FROM x WHERE rn > 1;
If you want to delete the duplicate rows:
;WITH x AS
(
SELECT col1, col2, col3, rn = ROW_NUMBER() OVER
(PARTITION BY col1, col2, col3 ORDER BY id)
FROM dbo.tbl
)
DELETE x WHERE rn > 1;

Note: If you want to find duplicate rows based on a single row the query is easier:
delete from tbl
where id NOT in
(
select  min(id)
from tbl
group by sourceid
)

Wednesday, 7 May 2014

WPF - How to use FileOpenDialog, SaveFileDialog, PrintDialog

Unlike in Windows Forms, WPF doesn't have a FileOpenDialog component in the Controls toolkit.
But you can access the Dialogs classes from Microsoft.Win32 namespace.
A sample usage is as below:
// Configure open file dialog box
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".txt"; // Default file extension
dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension

// Show open file dialog box
Nullable<bool> result = dlg.ShowDialog();

// Process open file dialog box results
if (result == true)
{
// Open document
string filename = dlg.FileName;
}

Similarly you can use other DialogBoxes from the namespace like:
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();

Tuesday, 6 May 2014

C# - How to check if a column exists in a DataRow

It's a common requirement when you work with DataRows to check if a column exists. The next check would be if the column has a value which we will see afterwards in this post.

To check if a column exists:
dRow.Table.Columns["msisdn"] == null
The row doesn't contain a column property as such. Therefore you will have to get into the Parent table property to check into the columns in the row.

Note:
If the column doesn't exist,
dr["msisdn"] == null
will throw and error.

To check if a column has value and is not null value:
dr["msisdn"] == DBNull.Value
and
if(dr.IsNull("msisdn"))
are used to check if a column has value

Wednesday, 23 April 2014

Install Telnet Client on Windows

You must be logged in as a user with Administrator role to add Telnet client capabilities.

  • Install Telnet Client by using a command line
    • Supported OS: Windows 8/7/Vista, Windows Server 2008
    • Steps:
      • Open a command prompt window. Click Start, type cmd in the Start Search box, and then press ENTER.
      • Type the following command: pkgmgr /iu:"TelnetClient"
    • Note: If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
    • When the command prompt appears again, the installation is complete.
    • Yes, its as simple as that from the command line. :)
  • Install Telnet Client on Windows Server (2008 or >) using Management Console
    • Use the Role Management tool.
    • Steps:
      • Start Server Manager. Click Start, right-click Computer, and then click Manage.
      • If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
      • In the Features Summary section, click Add features.
      • In the Add Features Wizard, select Telnet Client, and then click Next.
      • On the Confirm Installation Options page, click Install.
      • When installation finishes, on the Installation Results page, click Close.
  • Install Telnet Client on Windows 8/7/Vista from Control Panel
    • Use the Windows Features tool.
    • Steps:
      • Click Start, and then click Control Panel.
      • On the Control Panel Home page, click Programs.
      • In the Programs and Features section, click Turn Windows features on or off.
      • If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
      • In the Windows Features list, select Telnet Client, and then click OK.

Thursday, 3 April 2014

Check installed .NET version - Command line

Here is a quick and easy way to find the .NET versions installed on your machine.
This can be used on any machine either development or server machines.
In this method, the .NET framework installation directories are listed corresponding to the installed framework versions.
Use the command to list the framework versions.
dir %WINDIR%\Microsoft.Net\Framework\v*
For a more polished output use the below command.
dir %WINDIR%\Microsoft.Net\Framework\v* /O:-N /B

HTTPHandler Error - 404 Not Found

If your Web.Config is like below:
<httpHandlers>
<add verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</httpHandlers>
or
<handlers>
<add name="MyHandler" verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</handlers>
When you navigate to http://myserver/myApp/myhandler.api, if it gives server error 404 Not Found error, it might be the web config settings that might be the issue.
Solution:
If you are using IIS7, check in which mode your application pool is configured (Check the properties of  Application Pool in IIS Manager for Managed Pipeline mode).
1) If your application pool running in Classic mode, then the handler reference need to go into the following section:
<system.web>
<httpHandlers>
</httpHandlers>
</system.web>
example:
<system.web>
<httpHandlers>
<add verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</httpHandlers>
</system.web>
2) If your application pool running in Integrated pipelined mode, then the handler reference need to go into the following section:
<system.webServer>
<handlers>
</handlers>
<system.webServer>
example:
<system.webServer>
<handlers>
<add name="MyHandler" verb="*" path="myhandler.api" type="MyAssembly.MyHandlerClass, MyAssembly"/>
</handlers>
<system.webServer>

Saturday, 8 March 2014

Windows Phone - TextWrap in TextBlock

How to enable text wrapping in Windows Phone XAML TextBlock.
Its simple by setting the "TextWrapping" property to "Wrap".

<TextBlock Text="{Binding}" TextWrapping="Wrap"/>

Windows Phone - Set the width of Grid to 100%

I have a ListBox and within its ItemTemplate, I have a Grid, and the Grid has rows with 2 columns each.
My intention is to have the ListBox stretch to 100%. Also the grid inside each ListBoxItems to stretch to 100% of the screen size. The grid's 1st column is to occupy 80% and 2nd column 20% of the screensize.

All the above settings I want to have without explicitly setting the width in pixels (px), but have it by percentages so that according to different screen widths and orientations (Portrait/ Landscape), the controls re size themselves accordingly.

<StackPanel HorizontalAlignment="Stretch">
<TextBlock Text="Sample" />
<ListBox Name="MyListBox">
    <ListBox.ItemTemplate>
        <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0">
                        <TextBlock Text="Hello" />
                    </Grid>
                    <Grid Grid.Column="1">
                        <TextBlock Text="Hello" />
                    </Grid>
            </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
</StackPanel>

To make the design fluid based on percentages, I would change the xaml as below:
<StackPanel HorizontalAlignment="Stretch">
<TextBlock Text="Sample" />
<ListBox Name="MyListBox">
    <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            </Style>
        </ListBox.ItemContainerStyle>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="8*"/>
                    <ColumnDefinition Width="2*"/>
                </Grid.ColumnDefinitions>
            <Grid Grid.Column="0">
                <TextBlock Text="Hello" />
            </Grid>
            <Grid Grid.Column="1">
                <TextBlock Text="Hello" />
            </Grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
</StackPanel>

We have added a styling to ListBoxItem as below:
<Style TargetType="ListBoxItem">
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    </Style>
</ListBox.ItemContainerStyle>
This ensures that the ListBoxItem contents stretches to 100%.

Next changes are on the Grid Control inside the ListBox.
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="8*"/>
        <ColumnDefinition Width="2*"/>
    </Grid.ColumnDefinitions>
<Grid Grid.Column="0">
We want the first column to consume 80% of the width of the Grid and second column to occupy 20%.
Unlike HTML, XAML doesn't directly support percentages.
We specified 8* and 2*. How it works is as follows:
With the * is works as a ratio. The total width ratio (100%) is calculated on runtime as 10 (8+2).
Out of which 80% (8 out of 10) is first column and 20% (2 out of 10) is second column.
Having said that you would already have guessed that instead of 8* and 2*, 80* and 20* also works. This is correct as it works based on ratio.


Monday, 3 March 2014

ASP.NET - The type exists in both temp123.dll and temp456.dll

ASP.Net error: The type 'abc' exists in both "temp123.dll" and "temp456.dll

This is a common issue occuring in ASP.NET Web Application Projects. This is an age old issue in ASP.NET. At random, the pages gives error CS0433, saying the type exists in multiple DLLs.
These dlls are generated and located in "Temporary ASP.NET Files" directory. The error occurs most in pages using user controls.

A sample of this error is as below:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0433: The type 'myusercontrol_ascx' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\sb2\4d76034e\bec2c8d0\App_Web_myusercontrol.ascx.abcd7d2.zyxwv5k.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\sb2\4d76034e\zyxwv0\App_Web_abcde.dll'


Solution
In the "compilation" element of web.config file, add the attribute "batch" and set its value to "false"
<configuration ...>
  <system.web>
    <compilation ... batch="false"/>


This problem occurs because of the way in which ASP.NET 2.0 uses the application references and the folder structure of the application to compile the application. If the batch property of the element in the web.config file for the application is set to true, ASP.NET 2.0 compiles each folder in the application into a separate assembly.

Monday, 24 February 2014

WindowsPhone 8 - Using "&" ampersand in QueryString Parameter

If you have "&" ampersand or any other url-reserved characters like "?" as part of your querystring paramter value, you will have to encode the value before passing it to the other page.

In .NET you can use the framework helper method HttpUtility.UrlEncode to encode the string containing "&" and in the target Page use the HttpUtility.UrlDecode helper method.

In windows phone the same helper methods are available in namespace System.Net.HttpUtility.

An alternate option is to use the Silverlight Uri.EscapeUriString and Uri.EscapeDataString

Usage:
//To Escape:
string encodedValue = Uri.EscapeDataString("William&Shakespeare");
NavigationService.Navigate(new Uri("/Page2.xaml?author=" + encodedValue, Urikind.Relative));

//To Unescape:

string encodedValue = NavigationContext.QueryString["author"];
string author = Uri.UnescapeDataString(encodedValue);

Friday, 17 January 2014

Windows 8 - RDP using Blank Password

On Windows machines, by default you are not permitted to establish a Remote Desktop connection with a user account having a NULL (Blank) Password.
Trying to do so, you might come across error messages like:
"Unable to log you on because of an account restriction."

As a matter of fact this is the case not only with Remote Desktop connections, but also with any logon attempts to a Windows machine over network with a blank password.

The first work around for this behavior is to set a password for the user account and use it to logoon remotely. But I guess this is not what you are looking for right now. So lets look at the next option.

The second option allows you to logon with a blank pasword.
For this you will have to disable blank password restrictions using a policy on the machine. Follow the below simple steps on the machine to which you want to establish remote desktop connection.

  1. Click Start, point to Run, type gpedit.msc, and then click OK to start the Group Policy Editor.
  2. Open Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options\Accounts: Limit local account use of blank passwords to console logon only.
  3. Double-click Limit local account use of blank passwords to consol logon only.
  4. Click Disabled, and then click OK.
  5. Quit Group Policy Editor.
You might have to restart / log off and login to the machine to which you want to establish the remote connection before you try the remote connection with blank password.

Tuesday, 7 January 2014

Winforms C# - AutoComplete for Textbox and ComboBox

Recently I came across the autocompletion feature in WinForms TextBox control.
My requirement was to have an autocomplete textbox with the file paths and file names like windows explorer address bar.
Instead of writing the whole functionality myself I was really excited to find the built in autocomplete feature with windows forms controls.
You need to set 2 properties (AutoCompleteSource and AutoCompleteMode) of Textbox and ComboBox controls to use the built in AutoComplete features. The properties can be set either at design time or at runtime via code.

Both the properties are enumerations. The values are explained below:

AutoCompleteSource Enumeration :
  • AllSystemResources – Specifies the equivalent of FileSystem and AllUrl as the source. This is the default value when AutoCompleteMode has been set to a value other than the default.
  • AllUrl – Specifies the equivalent of HistoryList and RecentlyUsedList as the source.
  • CustomSource – Specifies strings from a built-in AutoCompleteStringCollection as the source.
  • FileSystem – Specifies the file system as the source.
  • FileSystemDirectories – Specifies that only directory names and not file names will be automatically completed.
  • HistoryList – Includes the Uniform Resource Locators (URLs) in the history list.
  • ListItems – Specifies that the items of the ComboBox represent the source.
  • None – Specifies that no AutoCompleteSource is currently in use. This is the default value of AutoCompleteSource.
  • RecentlyUsedList – Includes the Uniform Resource Locators (URLs) in the list of those URLs most recently used.
AutoCompleteMode enumeration:
  • Append – Appends the remainder of the most likely candidate string to the existing characters, highlighting the appended characters.
  • None – Disables the automatic completion feature for the ComboBox and TextBox controls.
  • Suggest – Displays the auxiliary drop-down list associated with the edit control. This drop-down is populated with one or more suggested completion strings.
  • SuggestAppend – Applies both Suggest and Append options

Example: AutoComplete with file path on typing in the Textbox. (Like Windows Explorer Address Bar and Run Dialog)
Textbox1.AutoCompleteSource = AutoCompleteSource.FileSystem;
Textbox1.AutoCompleteMode = AutoCompleteMode.Suggest;