List/Grid C# Subscribe RSS feed of category C#
How To Take Registry Access In Your C# Application
When you try to modify Registry keys either by adding some Registry Keys or Values or by editing existing ones, then you get an error about Access Denied. In that case you have to give your program more access to change Registry Entries. This is not about Administrative Privileges, but more Control over that. Let me explain this all to you. You can consider this that Registry Entries can have…
How To Create An Image Button In C#
You can easily embed an image in Button control, which makes your button looks attractive in Windows Form. But note that the image you want to embed into button must be a Resource file. Just follow the instructions and you will be able to create this kind of button for yourself. Instructions: Create a Button control on your Windows Form and then open its properties. In its properties, change the…
How To Read Value From Registry Key Using C#
In this tutorial, I will show you How To Read Registry Keys using C#. For this purpose, Microsoft has provided Registry and RegistryKey classes in Microsoft.Win32 class in .NET library. I will show you quick ways on how can we read Registry Keys and its Value, finding how many values a Registry Key have, and also how many sub keys are present in a particular key. Instructions: Add following namespace…
How To Force C# Application To Only Run As Administrator In Windows
If you are creating an Application which will target secured file on Client’s Computer, then your Application need to Run with Administrative Privileges, otherwise your Application will surely fail in its operation. Say, you want to create an Application which will try to edit or create Registry Entries or tries to access Program Files or any kind of Operating System (Windows) files, then your Application will fail, if it does…
How To Pass Command Line Arguments In C#
We can pass Command Line Arguments in C# which are handled as parameters in the Main function of our program. In this article I will show you how can we pass Command Line Arguments in a C# program and then how to access them in our program. In C#, You can only pass String type Arguments using Command Line. If you want to pass Arguments of other type, you have…
How To Read A File Line By Line Using C#
In this article, I will talk about, how can we read a file line by line in C#. For this purpose, I will use StreamReader class present in .NET Framework. Instructions: Start by adding System.IO namespace in your code. using System.IO; Now create a new instance of StreamReader class and pass the path of your file as a parameter in the Constructor. StreamReader sr = new StreamReader(@"D:\HowToIdeas\text.txt"); Now you can…
How To Find Startup Path Of Any Process Using C#
You can easily fetch the Startup path of any process working in your System using C#. You can only get Startup path of those processes which are currently running. So, In this article, I will talk about how can we get Startup path of currently running processes. Instructions: Add a Namespace in your application using system.diagnostics; Now Loop through all the running processes, and find the process whose path you…
How To Run Any Application Or Process Using C#
You can easily run any external application or program using C#. If you want to run any installed application, then you just need to know the name of executable file of that application. Otherwise you can run any process by knowing its Startup Path. Instructions: If you want to run an installed application, just find out its executable file name from properties of that application. Now in your C# application,…
How To Capture Information About A File In C#
You can view file properties by right clicking on any file and then choosing Properties from the right click context menu. In this article, I will show you a simple way which you can use to get most of the information present in that properties dialogue by using C#. I will use FileInfo class which enables us to get information about specific file. Instructions: Create a new FileInfo class instance…