How can I make this command do the Opposite?

01/29/2010 21:38 copz1337#1
How can I change this command to delete an account in my folder of Users instead of creating?

Code:
                    if (Cmd[0] == "/newacc" && Cmd.Length > 2)
                    {
                        if (Cmd.Length == 3)
                            Database.CreateAccount(Cmd[1], Cmd[2], "");
                        else
                            Database.CreateAccount(Cmd[1], Cmd[2], Cmd[3]);
                    }
01/29/2010 21:54 Jedex#2
You can't.
01/29/2010 22:47 copz1337#3
Quote:
Originally Posted by Jedex View Post
You can't.
That doesn't help. I don't listen to people that say "You can't do it".
01/29/2010 23:14 .Kob#4
Yes, you can obviously -.-
01/29/2010 23:37 Korvacs#5
You would need to write a new DeleteAccount method which would remove an account from your database.

And then write a new command for it.
01/29/2010 23:57 Arcо#6
Quote:
Originally Posted by Jedex View Post
You can't.
You don't know anything about c# to be honest so you have no right to say that.

@OP
Make it find the account from the accounts folder and delete it.
Does that help?
01/30/2010 00:15 spare2#7
Code:
        public static void DeleteAccount(string Name)
        {
            if (File.Exists(@"C:\OldCODB\Users\" + Name + ".usr"))
            {
                File.Delete(@"C:\OldCODB\Users\" + Name + ".usr");
            }
        }
Code:
                    if (Cmd[0] == "/delacc" && Cmd.Length > 1)
                    {
                        Database.DeleteAccount(Cmd[1]);
                    }
01/30/2010 00:21 -Shunsui-#8
Quote:
Originally Posted by spare2 View Post
Code:
        public static void DeleteAccount(string Name)
        {
            if (File.Exists(@"C:\OldCODB\Users\" + Name + ".usr"))
            {
                File.Delete(@"C:\OldCODB\Users\" + Name + ".usr");
            }
        }
Code:
                    if (Cmd[0] == "/delacc" && Cmd.Length > 1)
                    {
                        Database.DeleteAccount(Cmd[1]);
                    }
Owned,? Looks like it would work,
01/30/2010 00:47 copz1337#9
Yeah I'll try that command in a sec. Anyways I found this on google. Haven't tested either oh well.

#edit- yeah the command worked, thanks Spare2.

Code:
// Simple synchronous file deletion operations with no user interface.
// To run this sample, create the following files on your drive:
// C:\Users\Public\DeleteTest\test1.txt
// C:\Users\Public\DeleteTest\test2.txt
// C:\Users\Public\DeleteTest\SubDir\test2.txt

public class SimpleFileDelete
{
    static void Main()
    {
        // Delete a file by using File class static method...
        if(System.IO.File.Exists(@"C:\Users\Public\DeleteTest\test.txt"))
        {
            // Use a try block to catch IOExceptions, to
            // handle the case of the file already being
            // opened by another process.
            try
            {
                System.IO.File.Delete(@"C:\Users\Public\DeleteTest\test.txt");
            }
            catch (System.IO.IOException e)
            {
                Console.WriteLine(e.Message);
                return;
            }
        }

        // ...or by using FileInfo instance method.
        System.IO.FileInfo fi = new System.IO.FileInfo(@"C:\Users\Public\DeleteTest\test2.txt");
        try
        {
            fi.Delete();
        }
        catch (System.IO.IOException e)
        {
            Console.WriteLine(e.Message);
        }

        // Delete a directory. Must be writable or empty.
        try
        {
            System.IO.Directory.Delete(@"C:\Users\Public\DeleteTest");
        }
        catch (System.IO.IOException e)
        {
            Console.WriteLine(e.Message);
        }
        // Delete a directory and all subdirectories with Directory static method...
        if(System.IO.Directory.Exists(@"C:\Users\Public\DeleteTest"))
        {
            try
            {
                System.IO.Directory.Delete(@"C:\Users\Public\DeleteTest", true);
            }

            catch (System.IO.IOException e)
            {
                Console.WriteLine(e.Message);
            }
        }

        // ...or with DirectoryInfo instance method.
        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(@"C:\Users\Public\public");
        // Delete this dir and all subdirs.
        try
        {
            di.Delete(true);
        }
        catch (System.IO.IOException e)
        {
            Console.WriteLine(e.Message);
        }

    }
}