Jump to content


Check out our Community Blogs

Jarryd

Member Since 05 Sep 2010
Offline Last Active Nov 03 2012 01:11 AM
-----

#633328 BitLocker

Posted by Jarryd on 07 July 2012 - 03:45 AM

Start -> Control Panel -> System and Security -> BitLocker Drive Encryption -> Locate the drive on which you want to disable BitLocker -> Turn Off BitLocker

Once completing these steps correctly you will be informed that the drive will be decrypted and that decryption may take some time. Click 'Decrpyt the Drive' to continue and turn off the BitLocker protection on the drive.

If this does not work, please provide a screenshot or the full error message.
  • 1


#598743 Visual C# : File System Watcher (basics)

Posted by Jarryd on 03 May 2011 - 12:23 AM

Difficulty: 2 / 10
Assumed Knowledge: Very little knowledge of C#.
Information: Listens to the file system notifications and raises events when a directory, or file in a directory, has changed, been created, renamed and even deleted.
requirements: fileSystemWatcher module.

Posted Image

Step 1: Adding functions
Form 1: - Load
            fileSystemWatcher1.Path = "C:/";
            fileSystemWatcher1.Filter = "*.*";

            fileSystemWatcher1.IncludeSubdirectories = true; 
            // Allows the file system watcher to search though sub firectories

            fileSystemWatcher1.EnableRaisingEvents = true;
            // Gets or sets a value indicating whether the component is enabled.
This sets the path and the filter to pick up certain file formats, by setting the subdirectories true the fileSystemWatcher will search though all sub directories, Enable raising event gets or sets a value indicating whether the component is enabled.

Step 2: adding unimplemented methods
private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
        {
            listBox1.Items.Add("File (" + e.ChangeType + ") : " + e.FullPath);
            // Tells the user that something in the system has been changed.
        }

        private void fileSystemWatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
        {
            listBox1.Items.Add("File (" + e.ChangeType + ") : " + e.FullPath);
            // Tells the user that something in the system has been Created.
        }

        private void fileSystemWatcher1_Deleted(object sender, System.IO.FileSystemEventArgs e)
        {
            listBox1.Items.Add("File (" + e.ChangeType + ") : " + e.FullPath);
            // Tells the user that something in the system has been Deleted.
        }

        private void fileSystemWatcher1_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            listBox1.Items.Add("File (" + e.ChangeType + ") : " + e.FullPath);
            // Tells the user that something in the system has been renamed.
        }
[Note: These methods may need to be written - not c&p]
These methods, will tell the user if a file is changed, created, renamed and even deleted.
  • 1


#585053 How do I find a file in C#?

Posted by Jarryd on 24 December 2010 - 04:29 PM

To search for files / folders, you first need to add the IO class...

using System.IO;

Once that has been added you can now add the main part of the code,

if (File.Exists(textBox1.Text))
            {
                MessageBox.Show(textBox1.Text + " was found on your system...");
            }

That code will search your computer for an existing file of your choice (using a textbox for the location)

The same applies for folders...

if (Directory.Exists(textBox1.Text))
            {
                MessageBox.Show(textBox1.Text + " was found on your system...");
            }

Posted Image

Posted Image
  • -1


#577341 Happy Birthday CodeCall!

Posted by Jarryd on 20 October 2010 - 12:36 AM

I found this forum on google a few months ago (#1 on the list :D) and decided to stay for plenty of reason, The main is that the codecall community is massive, and everyone is so nice, and polite Another reason is that everyone has much knowledge to share, no question goes un-answered! :)
  • 1


#576382 Visual C# : Basic Log Files (Console Application)

Posted by Jarryd on 12 October 2010 - 01:58 AM

Basic Log File (Console Application)



Difficulty: 2 / 10 : Depending on your knowledge with the C# language.
Assumed Knowledge: Basic knowledge of the try/catch statement.
Information: This tutorial teaches you the basic knowledge of creating logfiles in C#.

One of the simplest, yet very flexible, manners for storing information is within a text file. Such a file allows the storage of data in a human-readable and easily edited format. You can create text files using the .NET framework's StreamWriter class.


Step 1: Starting the Project

Begin this project by creating a new console application in visualo C#.


Posted Image

Step 2: Setting the Console up
For this to work properly, we will need to add System.IO

using System.IO;

I/O is Short for input/output. The term I/O is used to describe any program, operation or device that transfers data to or from a computer and to or from a peripheral device. Every transfer is an output from one device and an input into another.

Step 3: Starting the main Process
We will now need to add two variables.

string strText;
            StreamWriter logFile;

Information can be written to the StreamWriter, and ultimately the file, using two of the class' methods. The WriteLine method stores an entire line of characters, ending with a carriage return in readiness for a new line. The simplest variation requires a string parameter containing the characters to be written.

and allow the console to read input from the user.

Console.Write("Name: ");
            strText = Console.ReadLine();

The try/catch statement consists of a try block followed by one or more catch clauses, which specify handlers for different exceptions. When an exception is thrown, the common language runtime (CLR) looks for the catch statement that handles this exception. If the currently executing method does not contain such a catch block, the CLR looks at the method that called the current method, and so on up the call stack. If no catch block is found, then the CLR displays an unhandled exception message to the user and stops execution of the program.

try
            {

            }
            catch (Exception ex)
            {

            }

The StreamWriter class is a standard class within the System.IO namespace. The class allows character data to be sent to a stream, including a text file, for recording or processing. The character data can be sent with various standardised encoding options such as UTF, Unicode, etc.

try
            {
                if (!File.Exists("Log.txt"))
                {
                    logFile = new StreamWriter("Log.txt");
                }
                else
                {
                    logFile = File.AppendText("Log.txt");
                }

                logFile.WriteLine(DateTime.Now);
                logFile.WriteLine(strText.ToString());
                logFile.WriteLine();

                Console.WriteLine("Log file saved successfully!");

                logFile.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                goto A;
            }

Often you will need to append text to an existing file, rather than simply overwriting it. An overloaded version of the StreamWriter constructor allows you to specify whether you wish to overwrite or append by adding a Boolean parameter. If the parameter is set to true, text sent to the StreamWriter will be added at the end of the existing information. If set to false, the file will be replaced. In either case, if the specified file does not exist it will be created.


Once all of the required information has been written to the file, you should call the StreamWriter's Close method. This ensures that any buffered information is sent to the stream and frees any resources that are in use. Once the StreamWriter is closed, the text file will be complete.

Finished Source Code:
using System;
using System.IO;

namespace logFiles
{
    class Program
    {
        static void Main()
        {
            string strText;
            StreamWriter logFile;

        A:
            Console.Write("Name: ");
            strText = Console.ReadLine();

            try
            {
                if (!File.Exists("Log.txt"))
                {
                    logFile = new StreamWriter("Log.txt");
                }
                else
                {
                    logFile = File.AppendText("Log.txt");
                }

                logFile.WriteLine(DateTime.Now);
                logFile.WriteLine(strText.ToString());
                logFile.WriteLine();

                Console.WriteLine("Log file saved successfully!");

                logFile.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                goto A;
            }

            Console.Read();
        }
    }
}

Posted Image

Posted Image
  • 2


#575564 Random insult generator!

Posted by Jarryd on 05 October 2010 - 02:35 AM

this would be so much easier and more understandable if you were running case's...

for example:

Dim randomInsult As String
        randomInsult = Int(Rnd() * 4)

        Select Case randomInsult
            Case 1
                MsgBox("How bad are their teeth")
            Case 2
                MsgBox("Eh not too bad")
            Case 3
                MsgBox("Terrible")
            Case 4
                MsgBox("Makes children cry")
        End Select

  • -1


#574478 C# : Application Launcher (Console Application)

Posted by Jarryd on 24 September 2010 - 06:59 PM

Application Launcher (Console Application)



Difficulty: 2 / 10
Assumed Knowledge: Basic methods and functions of Visual Basic.
Information: This tutorial teaches you the knowledge of launching application.

This little project allows you to luanch an application through your console.


Step 1: Setting the console up

To start this project, you will need to create a new visual C# console.


Posted Image

Step 2: Adding variables
Class:
namespace Launch_Sample__console_
{
    class Program
    {
        static void Main()
        {

        }
    }
}

Using statements:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Diagnostics;

Step 3: Starting the main process

Starting the main part of the console.


String txtApp;

            Console.Write("Option: ");
            txtApp = Console.ReadLine();

Step 4: Try / Catch statement
try
            {
                Process.Start(txtApp);
                Console.WriteLine("Application: " + txtApp + ", Sucessfully Launched!");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.Read();

If the input the user types is correct, the application that matches the users input will run, But if the input the users type is incorrect, and does not match an application it will not run.

A Process component provides access to a process that is running on a computer. A process, in the simplest terms, is a running application. A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the code of the process, including parts currently being executed by another thread.


Finished Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

// Jarryd Hoffman

namespace Launch_Sample__console_
{
    class Program
    {
        static void Main()
        {
            String txtApp;

            Console.Write("Option: ");
            txtApp = Console.ReadLine();

            try
            {
                Process.Start(txtApp);
                Console.WriteLine("Application: " + txtApp + ", Sucessfully Launched!");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.Read();
        }
    }
}

Success:
Posted Image

Fail:
Posted Image

Images uploaded with ImageShack.us


  • 1


#573723 Visual Basic 2010 : Port Scanner (Console)

Posted by Jarryd on 17 September 2010 - 05:25 PM

Port Scanner (Console Application)


Difficulty: 3 / 10 : Depending on your knowledge of the Visual Basic language.
Assumed Knowledge: Basic knowledge of Visual Basic, Basic knowledge of TCP (Transmission Control Protocol)
Information: This application connects to a TCP server and scans an IP showing all its ports whether there open or closed.

There are in total 65,535 ports but not every port is used. Below is a few known ports:

Port 20: FTP | Data port
Port 21: FTP | Control (Command) port
Port 23: Telnet | Unencrypted text communications
Port 25: SMTP | Used for e-mail routing between mailservers
Port 80: HTTP | HyperText Transfer Protocol


Step 1: Creating the Console

To start this project, you will need to create a new Visual Basic console


Posted Image

Step 2: Adding imports and Variables

Before we get carried away into the more interesting part, first we will need to add imports and other variables.


Imports:
Imports System.Net.Sockets
Imports System.Net
Imports System.Threading
Imports System.Text

These imports will allow us to extend our code, Making us able to use TcpClient() method, and to connect to it.

Class:
Public Class psAPP
    Public Shared Sub Main()

    End Sub
End Class

Variables:
Dim portStart As Integer
        Dim portEnd As Integer
        Dim lngPort As Long

        Dim txtHost As String
        Dim openPorts As Integer
        Dim closedPorts As Integer

We have declared a start and End variable to hold the From and To port numbers, When the port scanner is running, it will scan the ports in between the From and To numbers.

Step 3: Starting the main process


Starting the main part of the console,


Console.Write("Host: ")
        txtHost = Console.ReadLine()

        Console.Write("From: ")
        portStart = Console.ReadLine()

        Console.Write("To: ")
        portEnd = Console.ReadLine()

Doing this allows the user to key in input for the console to read,

If the user keys in these feilds correctly, When scanning it will connect to the Host, and scan From one port to the Other.

Step 4: Programming the TCP connections


This is were most of the work is done. Next, we are going to try to connect to the port, using a try/catch statement. If it connects, the port will come back saying it is open, If it does not connect, You will get the port number saying its closed.

For lngPort = portStart To portEnd
            Dim myTcpClient As New TcpClient()
            Try
                myTcpClient.Connect(txtHost, lngPort)
                Console.WriteLine("Host: " + txtHost + " : ")
                Console.WriteLine("     Port " + lngPort.ToString() + " : Open :")
                openPorts += 1
                myTcpClient.Close()
            Catch ex As SocketException
                Console.WriteLine("Host: " + txtHost + " : ")
                Console.WriteLine("     Port " + lngPort.ToString() + " : Closed :")
                ' Console.WriteLine(ex.Message)
                closedPorts += 1
            End Try
        Next

Now, in doing this, It will connect to the TCP server, Scan for the ports, And give the user an output wether it is open or closed.

You would of noticed myTcpClient.Close(), If it detects a port that is open, it will lcose the TCP connection to the current port using the Close() method.

Step 5: Finishing touches


This is optional, It just makes the scanner easier to use.


Console.Write("                                                              " & openPorts.ToString & " open port(s) : ")
        Console.Write("                                                           " & closedPorts.ToString & " closed port(s) : ")

        Console.Beep()
        Console.Write(txtHost + " : " + portStart.ToString + " - " + portEnd.ToString + " : Scanned Sucessfully")

Finished Source Code:
Imports System.Net.Sockets
Imports System.Net
Imports System.Threading
Imports System.Text

Public Class Tester
    Public Shared Sub Main()
        Dim portStart As Integer
        Dim portEnd As Integer
        Dim lngPort As Long

        Dim txtHost As String
        Dim openPorts As Integer
        Dim closedPorts As Integer

        Console.Title = CurDir() + " - Jarryd Hoffman"

        Console.ForegroundColor = ConsoleColor.DarkGreen

        Console.WriteLine("                                                            :: Jarryd Hoffman ::")

        Console.WriteLine("")

        Console.ForegroundColor = ConsoleColor.DarkGreen
        Console.Write("Host: ")
        Console.ForegroundColor = ConsoleColor.Gray
        Console.Write("")
        txtHost = Console.ReadLine()

        Console.ForegroundColor = ConsoleColor.DarkGreen
        Console.Write("From: ")
        Console.ForegroundColor = ConsoleColor.Gray
        Console.Write("")
        portStart = Console.ReadLine()

        Console.ForegroundColor = ConsoleColor.DarkGreen
        Console.Write("To: ")
        Console.ForegroundColor = ConsoleColor.Gray
        Console.Write("")
        portEnd = Console.ReadLine()

        Console.WriteLine("")

        For lngPort = portStart To portEnd
            Dim myTcpClient As New TcpClient()
            Try
                myTcpClient.Connect(txtHost, lngPort)
                Console.ForegroundColor = ConsoleColor.Gray
                Console.WriteLine("Host: " + txtHost + " : ")
                Console.WriteLine("     Port " + lngPort.ToString() + " : Open :")
                openPorts += 1
                myTcpClient.Close()
            Catch ex As SocketException
                Console.ForegroundColor = ConsoleColor.DarkGreen
                Console.WriteLine("Host: " + txtHost + " : ")
                Console.WriteLine("     Port " + lngPort.ToString() + " : Closed :")
                ' Console.WriteLine(ex.Message)
                closedPorts += 1
            End Try
        Next

        Console.WriteLine("")
        Console.ForegroundColor = ConsoleColor.Gray
        Console.Write("                                                              " & openPorts.ToString & " open port(s) : ")
        Console.ForegroundColor = ConsoleColor.DarkGreen
        Console.Write("                                                           " & closedPorts.ToString & " closed port(s) : ")
        Console.WriteLine("" & vbCrLf)
        Console.Beep()
        Console.Write(txtHost + " : " + portStart.ToString + " - " + portEnd.ToString + " : Scanned Sucessfully")

        Console.ReadLine()
    End Sub
End Class

Posted Image

If you have any information about this tutorial, Please don't hesitate to ask...


Images Uploaded with ImageShack.us


  • 1


#572871 Disable an applications close button (The X)

Posted by Jarryd on 08 September 2010 - 08:01 PM

Nice tutorial mate ;)

I might end up using something like this for one of my next projects.
  • -1


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download