What I want to do is be able to take text entries from a gump and output it into a text file on the server. Is this possible and what would I use to do it?
 
Try this
Code:
using System.IO;
...
		public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
		{
			using (TextWriter tw = File.CreateText(Path.Combine(Environment.CurrentDirectory, "THE_TEXTFILE_NAME.txt")))
			{
				tw.WriteLine($"The player {sender.Mobile.Name} sent this:");
				tw.WriteLine(info.TextEntries[0].Text);
			}
 
Thank you
[doublepost=1552860999][/doublepost]Well got a chance to try it. Everything compiles but am not getting any file output. This is the code I have atm:
Code:
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            switch(info.ButtonID)
            {
                case 0:
                {
                    break;
                }
                case 1:
                {
                    using (TextWriter tw = File.CreateText(Path.Combine(Environment.CurrentDirectory, "Staff_Rating.txt")))
                    {
                        tw.WriteLine("The player {sender.Mobile.Name} sent this:");
                        tw.WriteLine(info.TextEntries[2].Text);
                        tw.WriteLine(info.TextEntries[3].Text);
                        tw.WriteLine(info.TextEntries[4].Text);

                        break;
                    }
                }

            }
        }
 
Code:
tw.WriteLine("The player {sender.Mobile.Name} sent this:");

-->

Code:
tw.WriteLine($"The player {sender.Mobile.Name} sent this:");

<-->

Code:
tw.WriteLine("The player " + sender.Mobile.Name + " sent this:");
 
A little more help if anyone can. I have the whole thing working, but it is not working exactly the way I want it to be. I want to work like command logs are created, where the log is the same file but continues to add to it. This is the code I currently have.
Code:
case 1:
                {
                        if (!Directory.Exists("Logs"))
                            Directory.CreateDirectory("Logs");

                        var directory = Path.Combine("Logs", "Rating");

                        if (!Directory.Exists(directory))
                            Directory.CreateDirectory(directory);
                        try
                        {
                            using (TextWriter tw = File.CreateText(Path.Combine(directory, "" + info.TextEntries[1].Text + "_Rating.txt")))
                            {
                                tw.Flush();                           
                                tw.WriteLine("The player " + sender.Mobile.Name + " sent this rating");
                                tw.WriteLine("Staff Member:" + info.TextEntries[1].Text + " ");
                                tw.WriteLine("Rating:" + info.TextEntries[2].Text + " ");
                                tw.WriteLine("Comments:" + info.TextEntries[3].Text + " ");
                              
                            }
                        }
                        catch
                        {
                        }
                    break;
                }
 
The File.OpenWrite(String) was actually wrong. But, I did find what I needed from the link you posted.
It should File.AppendText(String)

Thank you for the assistance
 
Yes you are right, by default the OpenWrite doesnt append, it would still override it, AppendText is fine there :)
 
Back