Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

Ben Magee

@Ben Magee
About
Posts
16
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Vb.net & SQLite
    B Ben Magee

    Hi, I'm trying to design a login script using VB.net 2008 and the System.Data.SQLite wrapper. So far I have my SQLite tables setup with a default user (user: admin pass: test dob: 1990/01/01 name: John Smith) and I connect using the following code:

    Imports System.Data.SQLite

    Dim userName As String
    Dim passWord As String
    userName = usrBox.Text
    passWord = passBox.Text

    Dim sqlConnection As New SQLite.SQLiteConnection()

    Dim sqlCommand As New SQLiteCommand

    sqlConnection.ConnectionString = "Data Source=users.db3

    sqlConnection.Open()
    sqlCommand = sqlConnection.CreateCommand()
    sqlCommand.CommandText = "SELECT * FROM users WHERE username = " & userName

    However, I don't know how to check if the statement has rows for me to check if the user exists, and then I would have to do the same for passwords. Anyone know how to check if the statement has rows using a similar function? Cheers, Ben.

    Visual Basic csharp sqlite design tools

  • Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well)
    B Ben Magee

    Richard MacCutchan wrote:

    I think maybe you need to study the basics of C#.

    Did some studying, I now understand I need a public class with static variables inside to store data. Thanks for the advice (: Ben.

    C# csharp game-dev help lounge

  • Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well)
    B Ben Magee

    When the form loads, it generates all the numbers, and writes them to a file. When you press the button, it gets a random line from that file, and then the number on it, it then checks if the number is in a file with the numbers already called, if it isnt, it adds it to that file and then displays it. Forgive me, I am still relatively new to C# - and I am looking up on sharing variables between classes now. BtM.

    C# csharp game-dev help lounge

  • Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well)
    B Ben Magee

    Haha, I do try, but sometimes i need to use the data of the variable in a diffrent button control or something, and it wont let it. I tried settting it to something like: public void button1 but no luck :( Thanks, Ben.

    C# csharp game-dev help lounge

  • Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well)
    B Ben Magee

    Hi again, How would I store something in the computers memory? Ben.

    C# csharp game-dev help lounge

  • Visual C# 2010 - Application Crashes At A Certain Time (Causing VS2010 To Crash As Well)
    B Ben Magee

    Hi, I'm making a Bingo Generator for a assignment, but it generates the last number, then should you click the button again it crashes, also crashing VS2010 so I don't get a error either. here's the button code:

    var lineCount = 1;
    using (var reader = File.OpenText(@"saved.bingo"))
    {
    while (reader.ReadLine() != null)
    {
    lineCount++;
    }
    }

                TextWriter saveCalled = new StreamWriter("saved.bingo");
                saveCalled.Write(called.Text);
                saveCalled.Close();
    
                TextReader loadSaved = new StreamReader("saved.bingo");
                string saved = loadSaved.ReadToEnd();
                loadSaved.Close();
    
                randomGenerated.generate();
    
                TextReader nextBingo = new StreamReader("bingoNext.bingo");
                string bingoNum = nextBingo.ReadToEnd();
                nextBingo.Close();
    
                bingoNum = bingoNum.Trim();
    
                if (saved.Contains(bingoNum) == true)
                {
                    randomGenerated.generate();
                }
                else
                {
                    TextReader tr = new StreamReader("saved.bingo");
                    string saveNm = tr.ReadToEnd();
                    tr.Close();
    
                    int saveNum = saveNm.Count();
    
                    if (saveNum >= 15)
                    {
                        button1.Visible = false;
                        MessageBox.Show("Game Over.");
                    }
    
                    newnum.Text = bingoNum;
    
                    TextReader nextCalled = new StreamReader("calledNext.bingo");
                    string calledNum = nextCalled.ReadToEnd();
                    nextCalled.Close();
    
                    called.Text = calledNum;
                }
    

    and the generator code:

    namespace openBingo
    {
    public class randomGenerated
    {
    public static void generate()
    {
    System.Random linegrab = new System.Random(DateTime.Now.Millisecond);

            TextReader numRead = new StreamReader("numbers.bingo");
    
            ArrayList lines = new ArrayList();
    
            string line;
    
            while ((line = numRead.ReadLine()) != null)
            {
                lines.Add(line);
            }
    
            int randomIndex = linegrab.Next(lines.Count);
    
    
            string bingoNum = (lines
    
    C# csharp game-dev help lounge

  • [SOLVED] File Encryption Broken [modified]
    B Ben Magee

    Oops, My bad, i'd replaced the file so many times in testing I forgot to encrpypt it again :^)

    C# security help

  • [SOLVED] File Encryption Broken [modified]
    B Ben Magee

    Hello, I Am using the following functions to encrypt and decrypt files: Encrypt:

        private void EncryptFile(string inputFile, string outputFile)
        {
    
            try
            {
                string password = @"19651969"; // Your Key Here
                UnicodeEncoding UE = new UnicodeEncoding();
                byte\[\] key = UE.GetBytes(password);
    
                string cryptFile = outputFile;
                FileStream fsCrypt = new FileStream(cryptFile, FileMode.Create);
    
                RijndaelManaged RMCrypto = new RijndaelManaged();
    
                CryptoStream cs = new CryptoStream(fsCrypt,
                    RMCrypto.CreateEncryptor(key, key),
                    CryptoStreamMode.Write);
    
                FileStream fsIn = new FileStream(inputFile, FileMode.Open);
    
                int data;
                while ((data = fsIn.ReadByte()) != -1)
                    cs.WriteByte((byte)data);
    
    
                fsIn.Close();
                cs.Close();
                fsCrypt.Close();
            }
            catch
            {
                MessageBox.Show("Encryption failed!", "Error");
            }
        }
    

    Decrypt:

        private void DecryptFile(string inputFile, string outputFile)
        {
    
            {
                string password = @"19651969"; // Your Key Here
    
                UnicodeEncoding UE = new UnicodeEncoding();
                byte\[\] key = UE.GetBytes(password);
    
                FileStream fsCrypt = new FileStream(inputFile, FileMode.Open);
    
                RijndaelManaged RMCrypto = new RijndaelManaged();
    
                CryptoStream cs = new CryptoStream(fsCrypt,
                    RMCrypto.CreateDecryptor(key, key),
                    CryptoStreamMode.Read);
    
                FileStream fsOut = new FileStream(outputFile, FileMode.Create);
    
                int data;
                while ((data = cs.ReadByte()) != -1)
                    fsOut.WriteByte((byte)data);
    
                fsOut.Close();
                cs.Close();
                fsCrypt.Close();
    
            }
        }
    

    I'm using the following code to Decrypt my encrypted file, read it, then encrypt it again.

        private void Form1\_Load(object sender, EventArgs e)
        {       
            
            if (File.Exists("scf.sf"))
            {
                DecryptFile("scf.sf", "sff.sf");
                File.Delete("scf.sf");
                File.Move("sff.sf", "scf.sf");
    
    C# security help

  • Problem Reading And Writing Registry In C#
    B Ben Magee

    After changing my registry edits to CurrentUser and changing to backslashes im still getting my exception error. I also changed

    System.DateTime.Now;

    to

    system.DateTime.Today;

    would that work any better? Cheers, Ben.

    C# csharp com windows-admin help

  • Problem Reading And Writing Registry In C#
    B Ben Magee

    Thanks for the feedback, I will look into all these issues now. Could you please give a example of a lessthan statement in the current context im using? thanks, Ben.

    C# csharp com windows-admin help

  • Problem Reading And Writing Registry In C#
    B Ben Magee

    Hi guys, I have this code in my form1_load event:

            RegistryKey licenseCheck = Registry.LocalMachine.OpenSubKey(@"software/openorganise");
            string licenseCo = licenseCheck.GetValue("tlb").ToString();
           DateTime licenseDate = Convert.ToDateTime(licenseCo);
                if (licenseDate.AddDays(30) == System.DateTime.Now)
                {
                    MessageBox.Show("Your OpenOrganise License Has Expired. Please Purchase A New One.", "OpenOrganise Message.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Application.Exit();
                }
    

    now, ive got a config value that sets it to write to a file if its the first time run or not, etc etc, this works fine, in the event of a first run i have:

    RegistryKey licenseKey;
    licenseKey = Registry.LocalMachine.CreateSubKey(@"Software\openorganise");
    licenseKey.SetValue("tlb",DateTime.Now);
    Registry.LocalMachine.Flush();

    However, when running the application i get: "object referance not set to a instance of a object" Im stumped to as why. I even went and manually made the reg key. thanks, Ben.

    C# csharp com windows-admin help

  • Listboxes, Strings And Arrays
    B Ben Magee

    Legendary :D :D Thanks Alot :) Ben.

    C# help tutorial data-structures

  • Listboxes, Strings And Arrays
    B Ben Magee

    Hi, I'm probably missing something really simple here, but i'm stuck. Basically I have a listbox, which a user puts items into via a textbox and button, this works fine, the items go in. Now, on exit the items save to a text file, this also works fine, ive checked all the items are contained in the text file. Now, when the user re-opens the application there is a button called load previous items, when i click this i have a streamreader reading the text document, also works fine, checked with a messagebox, and it saves it to the string Now, I want the string to be saved into a array which is then put back into the textbox, the problem being, I dont know how to count the items in the string (each on a diffrent line) to put them into a array, and then after that I need a example of adding the array into my listbox. Im guessing its something to do with the listbox1.Addrange(); command. Cheers, Ben.

    C# help tutorial data-structures

  • Application Trial And StreamRead/Writer
    B Ben Magee

    I'm Aware of this fact, and I'm currently working on solutions to it :-) By hardware dongle do you mean memory stick? One of the solutions im looking at is creating the file with installation, then using a If statement to see if the file exists or not, if it does, then it writes to the file, if the file doesnt exist then the application will exit. True all the user would have to do then is make another file. But it should stop casual snoopers, All I really want it for is to make sure my friend doesnt leg it with a BETA release of some of my software, nothing too big. thanks All, Ben.

    C# question tutorial

  • Application Trial And StreamRead/Writer
    B Ben Magee

    Ok, Can you give a code example please? Thanks, Ben.

    C# question tutorial

  • Application Trial And StreamRead/Writer
    B Ben Magee

    Hi, Im making a trial of one of my applications, and i want the user to only be able to run the application 5 times.. now, my original plan had been:

    //WRITE VALUE TO TRIAL FILE
    int numint = 1;
    TextWriter trialWrite = new StreamWriter("oote.oost");
    trialWrite.WriteLine(numint+1);
    trialWrite.Close();

    So it would add +1 to the value of numint each time the application loads, but its not working right, and it doenst add to the number inside the text (oost) file in question. I also tried +1 but that doesnt work either. Its in the form_load event. Can anyone tell me how to add +1 to the value of the number already in my text file? thanks, Ben.

    C# question tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups