Jun 16, 2011

.Net code obfuscation/.Net dll obfuscation



.Net code obfuscation/ C# dll obfuscation




Obfuscation  In the context of software, obfuscation is the process of scrambling the symbols, code, and data of a program to prevent reverse engineering.In the context of software, obfuscation is the process of scrambling the symbols, code, and data of a program to prevent reverse engineering.


Please download it from http://eazfuscator.blogspot.com/ .
















We can do the obfuscation through code. It is very simple.


obfuscation  Add the following Piece of code  in a new file called ObfuscationSettings.cs
And the contents of the file will be as follows.


using System;
using System.Reflection;
[assembly: Obfuscation(Feature = "code control flow obfuscation", Exclude = false)]







Hope it helped u...
Cheers!!!!

Sandeep

Jun 7, 2011

Download a file from FTP server C#

Download a file from FTP server C#

In .Net it is always easy to write a piece of code as most of the functionalities are in built.
System.Net namespace inclusion does the work for you and it is very simple. 

Just go through the piece of code/function written below.
static void downloadFile()
        {
            //Create a WebClient.
            WebClient request = new WebClient();

            //Setup the credentials to the ftp server
            request.Credentials =
                new NetworkCredential("username",
                                        "password");

            //Download the data into a Byte array

            //@ is used to take the relative path
            byte[] fileData =
                request.DownloadData(@"Ftp path" + @"/" +
                                     @"Directorypath");

            //Create a FileStream that we'll write the byte array to.
                FileStream file =
                File.Create(@"C:\sand\Weekly Plan Excel-10-sep.xls");

            //Write the full byte array to the file.
            file.Write(fileData, 0, fileData.Length);

            //Close the file so other processes can access it.
            file.Close();
        }
        
it is as simple as that ...

Hope it helped u ....

Cheers!!!!!!!!!
Sandeep

Changing the WCF service start mode to automatic/manual

Changing the WCF service start mode to automatic/manual

Changing the wcf service to start mode or automatic is very easy. In initial stages i used to go to services.msc and change the start mode of my service to automatic or manual, but later on i found that changing the service mode is very easy and it can be done through the code.

First thing you need to do is add the INSTALLER CLASS to the wcf service project then view the code of the installer class.

Then follow the simple steps to make your service to run automatically or manually. The simplest change here is  to change the ServiceInstaller.StartType property
 Right this piece of code in the constructor of your installer class.

            InitializeComponent();
            ServiceProcessInstaller processInstaller = new ServiceProcessInstaller();
            ServiceInstaller serviceInstaller = new ServiceInstaller();

            //Specifies the type of account that should be used for the WCF service.
            processInstaller.Account = ServiceAccount.LocalSystem;
            //Specifies the name of the service that is installed.
            serviceInstaller.DisplayName = "//Specify the name of your service in the way how it should appear like in the services.msc";
            //Gives the description of the Installed service.
            serviceInstaller.Description = "Give the description of your service";
            //It tells which is the service that is installed.
            serviceInstaller.ServiceName = "Specify the name of the service here";
            //It specifies the Start type of the service.
            serviceInstaller.StartType = ServiceStartMode.Automatic;
            Installers.Add(processInstaller);
            Installers.Add(serviceInstaller);

So now you are in a great position to change the wcf service start mode.


Hope it helped you ...
Cheers...
Sandeep