CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Apr 2013

    pikck up a random out of a text file

    hi i got this code here id like for it to pick up a random word from a text file and use it as the nick in this line


    how could i do it heres the full code for the client

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using FluorineFx;
    using FluorineFx.Messaging.Adapter;
    using FluorineFx.Messaging.Api.Service;
    using FluorineFx.Net;
    using System.Threading;
    using System.IO;
    namespace koolscript
    class Client : IPendingServiceCallback
    private static Random rand = new Random();
    static string[] colors = { "#1965b6", "#32a5d9", "#7db257", "#a78901", "#9d5bb5", "#5c1a7a", "#c53332", "#821615", "#a08f23", "#487d21", "#c356a3" };
    static int colorIndex = 0;
    public NetConnection mNetConnection;
    private Thread thdHandler;
    public string roomName;
    public bool FlagDone = false;
    public const string MsgPath = "message.txt";
    public Client()
    public Client(string roomName)
    mNetConnection = new NetConnection();
    mNetConnection.OnConnect += OnConnect;
    mNetConnection.OnDisconnect += OnDisconnect;
    this.roomName = roomName;
    public void SetHandler(Thread thdHandler)
    this.thdHandler = thdHandler;
    private void OnConnect(object sender, EventArgs e)
    if (mNetConnection.Connected)
    SetNick("O" + GetRandomString(10) + "G");
    foreach (string msg in File.ReadAllLines(MsgPath))
    SendMessage(new Message(msg));
    FlagDone = true;
    private void OnDisconnect(object sender, EventArgs e)
    private void SetNick(string name)
    mNetConnection.Call("nick", this, name);
    private void SendMessage(Message message)
    if (colorIndex >= colors.Length)
    colorIndex = 0;
    string tmp = message.Format(',');
    string[] param = new string[] { tmp, colors[colorIndex] + ",en" };
    mNetConnection.Call("privmsg", this, param);
    private string GetRandomString(int length)
    rand = new Random(DateTime.Now.Millisecond / new Random().Next(2, 5));
    string tmpString = "";
    while (length-- > 0)
    tmpString += (char)rand.Next('a', 'z');
    return tmpString;
    public void ResultReceived(IPendingServiceCall call)
    throw new NotImplementedException();

  2. #2
    Join Date
    Feb 2011
    United States

    Re: pikck up a random out of a text file

    If I had to guess, this appears to be software intended to flood a chat system with a spam message. Discussion of such topics is not permitted by the CodeGuru Acceptable Use Policy (see http://forums.codeguru.com/aup.html). Therefore, I am closing this thread. If you have any questions, please contact me or an administrator.

    [Thread closed]
    Best Regards,

    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.