background preloader

C#

Facebook Twitter

C# Framework 4 (BTS 2012/2014)

Silent Installation Of Applications Using C# There will be situations where you will need to install applications silently without any human intervention. This is a pretty normal use case for System Administrators and they love to automate their tasks. In fact knowledge of this subject may be handy for any technology worker in various circumstances. In this article we will silently install FileZilla on to the computer. Before we proceed further, here are a few things to keep in mind: To install an application silently using the installer exe/package, you must use the Silent Switch for silent installation as described by the Vendor of the Software.

Scenario: In my case here I have the installer exes in "ApplicationRepository" folder in C drive as shown below. We will only be installing FileZilla as of now but you can extend it for any number of applications as you wish. Also let us make sure that FileZilla is not installed by looking at installed applications in Control Panel. Deploying/ Installing Application Thank You. Create a Remote Process using WMI in C# Download source - 16.53 KB Introduction This is a simple introduction for those who are looking at WMI as an option for remotely executing the process. I believe this is in no way the first of its kind article on The Code Project and I know there may be dozens of better articles. Leaving all these apart, I still believe this may help somebody new to the .NET world looking for a simple solution to execute the process remotely. Background This is not something I have conceptualized on my own and came up with this article here.

Using the Code If you have already downloaded the sample code, you must have noticed that this is a trivial command line application. Hide Copy Code sBatFile = @"\\" + remoteMachine + " So if we create the file using this variable (while you have admin access on the server), the file will be created on the remote server's Windows directory. Next, the program receives the remote command to execute and write into this file. Implémentation du Pattern Singleton en C# Il y a de nombreuses façons d'implémenter le pattern singleton en C#. Je les présenterai ici dans l'ordre inverse d'élégance, en commençant avec le plus communément vu (qui n'est pas « thread-safe ») et j'exposerai ensuite des versions avec chargement différé total, thread-safe, simple et hautement performante.

Toutes ces implémentations partagent quatre caractéristiques communes : un constructeur unique, qui est privé et sans paramètre. Ceci empêche d'autres classes de l'instancier (ce qui serait une violation du pattern). Notez que cela empêche aussi les sous-classes - si un singleton peut être sous-classé une fois, il peut être sous-classé deux fois, et si chacune de ces sous-classes peut créer une instance, le pattern est violé. Notez que toutes ces implémentations utilisent aussi une propriété publique statique nommée Instance comme moyen d'accéder à l'instance. Comme expliqué précédemment, l'exemple ci-dessus n'est pas thread-safe. Cette implémentation est thread-safe. Comment : écrire des paramètres utilisateur au moment de l'exécution avec C# Html Agility Pack - Home. How do U get the index of the current iteration of a foreach loop. Context Menu Strip. Définition des attributs d'assembly. Error VFW AFORGE dll Warning Target x86 see Forum.

Make an Installation program for C# applications and include .NET Framework installer into the setup.

Program

[C#]Chronomètre pour démineur. AForge.NET :: AreaProg. Comment : utiliser les modificateurs et les propriétés GenerateMember. Modifiers (C# Reference) Connect C# to MySQL. Introduction The purpose of this article is to show in a step by step manner how to use and connect C# with MySql using MySql Connect/NET. I will create simple examples about the DML (Insert, Update, Select, Delete) throughout the article to show how to query the database using C#, and in the end I will show you how to backup your database and save it in a .sql file from our application, and how to restore it back.

Getting Started Downloading Connector/Net First make sure you have downloaded and installed the MySQL Connector/NET from the MySQL official website. Creating the Database Now let's create the database, and the table that we are going to query from our application later on. From the command line, we start by creating the database: Hide Copy Code create database ConnectCsharpToMysql; Then we select the database to use before creating the table: use ConnectCsharpToMysql; And we create the table that we will query from our application: Using the Code Then we choose MySql.Data from the list:

Générateur de chaîne aléatoire c# Générateur de chaîne aléatoire c# J'ai mis au point un générateur de chaîne aléatoire, mais il ne se comporte pas tout à fait que je suis l'espoir. Mon but est de pouvoir exécuter ce deux fois et générer deux quatre chaînes aléatoires de caractères distincts. Cependant, il génère simplement une chaîne aléatoire de quatre caractères deux fois. Voici le code et un exemple de sa sortie : private string RandomString(int size) { StringBuilder builder = new StringBuilder(); Random random = new Random(); char ch; for (int i = 0; i < size; i++) { ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))); builder.Append(ch); } return builder.ToString(); } // get 1st random string string Rand1 = RandomString(4); // get 2nd random string string Rand2 = RandomString(4); // creat full rand stringstring docNum = Rand1 + "-" + Rand2; .. .et la sortie ressemble à ceci : UNTE-UNTE.. .mais il doit ressembler à ce UNTE-FWNU Comment puis-je m'assurer deux chaînes aléatoires distincts ?

Random.Next, méthode (System)