I am having multiple problems, there are going to be multiple usernames and passwords in the listbox...
I need the application to wait while and account is in the text boxes, and then when the textboxes are clear then the account next in the listbox can go to the next line..
Here is the code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net.Mail;
using System.Net;
using System.Text.RegularExpressions;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnOpenFile_Click(object sender, EventArgs e)
{
this.lbAccounts.Items.Clear();
OpenFileDialog Open = new OpenFileDialog();
Open.Title = "Select Email List";
Open.Filter = "Text Document|*.txt|All Files|*.*";
try
{
Open.ShowDialog();
StreamReader Import = new StreamReader(Convert.ToString(Open.FileName));
while (Import.Peek() >= 0)
lbAccounts.Items.Add(Convert.ToString(Import.ReadLine()));
}
catch (Exception)
{
}
}
private void SendTestMail()
{
try
{
NetworkCredential loginInfo = new NetworkCredential(txtUser.Text, txtPass.Text);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(txtUser.Text);
msg.To.Add(new MailAddress("example#gmail.com"));
msg.Subject = "Hi, I'm Valid :D";
msg.Body = txtUser.Text + ":" + txtPass.Text;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(msg);
lbGoodAccounts.Items.Add(txtUser.Text + ":" + txtPass.Text);
txtUser.Clear();
txtPass.Clear();
}
catch (Exception)
{
lbFailAccounts.Items.Add(txtUser.Text + ":" + txtPass.Text);
txtUser.Clear();
txtPass.Clear();
}
}
private void btnCheck_Click(object sender, EventArgs e)
{
SendTestMail();
}
private void btnExport_Click(object sender, EventArgs e)
{
StreamWriter Write;
SaveFileDialog Open = new SaveFileDialog();
try
{
Open.Filter = ("Text Document|*.txt|All Files|*.*");
Open.FileName = ("Good Gmail Accounts");
Open.ShowDialog();
Write = new StreamWriter(Open.FileName);
for (int I = 0; I < lbGoodAccounts.Items.Count; I++)
{
Write.WriteLine(Convert.ToString(lbGoodAccounts.Items[I]));
}
Write.Close();
}
catch (Exception ex)
{
MessageBox.Show(Convert.ToString(ex.Message));
return;
}
}
}
}
If I understood you right this is the code you will need :
void AccountsListBox_Click (object sender, EventArgs args)
{
if (AccountsListBox.SelectedIndex < 0)
return;
if (!string.IsNullOrEmpty(TextBoxName.Text) && !string.IsNullOrEmpty(TextBoxPass.Text))
return; // stop processing if they have some data
// otherwise get acccount:password,
// split it into acc and pass and write them to TextBoxes
string value = AccountsListBox.Items[AccountsListBox.SelectedIndex];
string[] values = value.Split(':');
if (values.Length != 2)
return; // wrong format
var acc = values[0];
var pass = values[1];
TextBoxName.Text = acc;
TextBoxPass.Text = pass;
}
I haven't used WinForms for some time so if you find some errors please correct them :)
See MSDN ListBox documentation for details.
Related
I am working in c-sharp .net and I am working on creating a login screen for my project. I have a text file with login info for all the users. My c-sharp scrip reads that file to a string then cuts it up into two lists, _usernames and _passwords. When the user types their login info and hits login the _usernames[0] and _passwords[0] account info are the only ones that work. What I want it to do is look through all the _usernames for the inputted one, if it finds it then check the _password[same index as _usernames] and if both are the same as what the user submitted then it will add "true" to the richTextBox.
Why is it not correctly reading from the array?
This is my users.txt:
admin,test|
andrew,yeet|
zana,happy|
This is my c-sharp script:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BaseUserInterfase
{
public partial class Login : Form
{
string path = Directory.GetCurrentDirectory() + "\\data\\users.txt";
string data;
string[] _usernames = new string[10];
string[] _passwords = new string[10];
public Login()
{
InitializeComponent();
}
private void Login_Load(object sender, EventArgs e)
{
GetLoginData();
}
private void btnLogin_Click(object sender, EventArgs e)
{
rtbTemp.Text = "";
for(int i = 0; i < _usernames.Length; i++)
{
if(_usernames[i] == null)
{
break;
}
rtbTemp.AppendText("\n" + _usernames[i]);
rtbTemp.AppendText("\n" + tbUsername.Text.ToString());
rtbTemp.AppendText("\n" + _passwords[i]);
rtbTemp.AppendText("\n" + tbPassword.Text.ToString());
if (_usernames[i] == tbUsername.Text.ToString())
{
rtbTemp.AppendText("\nUsername true");
if (_passwords[i] == tbPassword.Text.ToString())
{
rtbTemp.AppendText("\nPassword true");
rtbTemp.AppendText("\ntrue");
return;
}
}
}
rtbTemp.AppendText("\nfalse");
}
public void GetLoginData()
{
using (StreamReader streamReader = new StreamReader(path, Encoding.UTF8))
{
data = streamReader.ReadToEnd();
}
List<string> _data = data.Split('|').ToList();
_data.RemoveAt(_data.Count - 1);
rtbTemp.AppendText("\n");
Array.Resize<string>(ref _usernames, _data.Count);
Array.Resize<string>(ref _passwords, _data.Count);
foreach (string _item in _data)
{
List<string> userdata = _item.Split(',').ToList();
string username = userdata[0].ToString();
string password = userdata[1].ToString();
Console.WriteLine(_item);
Console.WriteLine(username);
Console.WriteLine(password);
for(int i = 0; i < _data.Count; i++)
{
if(_usernames[i] == null)
{
_usernames[i] = username;
_passwords[i] = password;
break;
}
}
}
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
And this is an image of the login screen:
1
Your file contains carriage return characters. Remove them before you split its content
data = streamReader.ReadToEnd().Replace("\r\n", "");
i am currently working on a Windows Forms App in c# which will allow the user to add or delete records. when i hit the button to display all the records written to the file the files appear, but when i try to delete by transact number i get an exception saying that "The process cannot access the the because it is being used somewhere else". i have tried putting it in a try-catch block to make sure the reader/writer will close and still not working code will be attached any help is greatly appreciated. p.s im not looking for code to finish this project just help getting by this exception and make it work like it is suppose.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MMFileIO
{
public partial class MMAssignment3 : Form
{
StreamWriter writer;
StreamReader reader;
string record = "";
public MMAssignment3()
{
InitializeComponent();
}
private void MMAssignment3_Load(object sender, EventArgs e)
{
txtFile.Text = #"c:\burnable\assignment3.txt";
if (!Directory.Exists(txtFile.Text.Substring
(0, txtFile.Text.LastIndexOf('\\'))))
MessageBox.Show("File path does not exist");
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
if (radNew.Checked)
writer = new StreamWriter(txtFile.Text, append: false);
else
writer = new StreamWriter(txtFile.Text, append: true);
}
catch(Exception ex)
{
if (writer != null)
writer.Close();
MessageBox.Show($"exception adding new record: {ex.Message}");
return;
}
record = $"{txtTransact.Text}::{txtDate.Text}::{txtSerial.Text}::" +
$"{txtToolPurchased.Text}::${txtPrice.Text}::{txtQty.Text}::" +
$"${txtAmount.Text}";
try
{
writer.WriteLine(record);
lblMessage.Text = ($"Record added");
txtTransact.Text = txtDate.Text = txtSerial.Text =
txtToolPurchased.Text = txtPrice.Text = txtQty.Text =
txtAmount.Text = "";
}
catch(Exception ex)
{
MessageBox.Show($"exception adding a new record: {ex.Message}");
}
finally
{
writer.Close();
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
reader = new StreamReader(txtFile.Text);
List<string> records = new List<string>();
while (! reader.EndOfStream)
{
record = reader.ReadLine();
records.Add(record);
}
if (records.Count == 0)
MessageBox.Show("No records left in file");
reader.Close();
writer = new StreamWriter(txtFile.Text, append: false);
foreach (string item in records)
{
}
}
private void btnCloseFile_Click(object sender, EventArgs e)
{
txtDataDisplay.Text = "";
reader.Close();
}
private void btnDisplay_Click(object sender, EventArgs e)
{
reader = new StreamReader(txtFile.Text);
txtDataDisplay.Text = $"{"#".PadRight(10)}\t" +
$"{"Purchase-Date".PadRight(10)}\t{"Serial #".PadRight(10)}\t" +
$"{"Manufacturing Tools".PadRight(10)}\t{"Price".PadRight(10)}\t" +
$"{"Qty".PadRight(10)}\t{"Amount".PadRight(10)}\n{"".PadRight(50)}\n";
while (!reader.EndOfStream)
{
record = reader.ReadLine();
string[] fields = record.Split(new string[] { "::" }, StringSplitOptions.None);
txtDataDisplay.Text += $"{fields[0].PadRight(10)}\t" +
$"{fields[1].PadRight(10)}\t{fields[2].PadRight(10)}\t" +
$"{fields[3].PadRight(30)}\t{fields[4].PadRight(10)}\t" +
$"{fields[5].PadRight(10)}\t{fields[6].PadRight(10)}\n";
}
reader.Close();
}
I have to send mails multiple times, when this is done multiple times by using smtpclient class, Memory is increasing drastically......
I have tried with following things...
- Calling dispose methods for MailMessage, smtpclient
- calling GC.collect method manually
Nothing helped me...
using System;
using System.Net.Mail;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
using (var smtpobj = new SmtpClient("smtp.gmail.com"))
{
mail.To.Add("xxx#gmail.com");
mail.From = new MailAddress("yyy#gmail.com");
mail.Subject = "subject - .net app";
mail.Body = "body";
smtpobj.Port = 587;
smtpobj.Credentials = new System.Net.NetworkCredential("yyy#gmail.com", "xyz");
smtpobj.EnableSsl = true;
smtpobj.Send(mail);
}
}
catch(Exception ex)
{
string strReturn = ex.ToString();
MessageBox.Show(strReturn);
}
}
}
}
Try the following:
using System;
using System.Net.Mail;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
using (var smtpobj = new SmtpClient("smtp.gmail.com"))
{
mail.To.Add("xxx#gmail.com");
mail.From = new MailAddress("yyy#gmail.com");
mail.Subject = "subject - .net app";
mail.Body = "body";
smtpobj.Port = 587;
smtpobj.Credentials = new System.Net.NetworkCredential("yyy#gmail.com", "xyz");
smtpobj.EnableSsl = true;
smtpobj.Send(mail);
smtpobj.ServicePoint.CloseConnectionGroup(
smtpobj.ServicePoint.ConnectionName);
}
}
catch(Exception ex)
{
string strReturn = ex.ToString();
MessageBox.Show(strReturn);
}
}
}
}
This is per: https://social.msdn.microsoft.com/Forums/vstudio/en-US/28b59c25-bc93-4285-860d-52f1f49d2d43/net-smtp-class-memory-leakage?forum=netfxbcl
I've got a weird issue here. I'll start by explaining my program:
I have a C# application. The main goal of the program is to get information about a book based on its ISBN. The ISBN is passed to the program via a TCP/IP scanner on an Android device. The ISBN is then put into a valid URL which is used to grab the XML data from ISBNDB.com.
The issue that I am having is this:
When I query an ISBN typed into a TextBox, the program works fine. When I query an ISBN scanned from the reader, it returns 'No Results'
I have implemented various ways to try and get to the bottom of this case. Right before the XML is read, I have a message box show me the XML that it received:
As you can see, it shows no results. However, when I visit the URL (Also gotten from within the program):
I get this in Microsoft Edge:
Which, is exactly what I would think the application would get as well.
Does anyone know what is going on? If so, what can I do to fix it and how can my code be improved to eliminate this error?
For those interested, here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using System.Threading;
using System.Diagnostics;
namespace LibraryBookLister
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string XML = "";
private void btnQuery_Click(object sender, EventArgs e)
{
GetXMLBarcodeData();
}
private void GetXMLBarcodeData()
{
string Barcode4 = textBarcode.Text;
MessageBox.Show(Barcode4);
string barcode = Barcode4;
StringBuilder output = new StringBuilder();
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Set the reader settings object to use the resolver.
if(barcode.Length > 13)
{
barcode = barcode.Remove(14);
MessageBox.Show(barcode);
}
string xmlString = #"?access_key=IDC057UX&results=details&index1=isbn&value1=" + barcode;
MessageBox.Show("GEttting book info for : " + barcode);
Uri baseUri = new Uri("https://isbndb.com/api/books.xml");
Uri fulluri = resolver.ResolveUri(baseUri, xmlString);
MessageBox.Show("Now Getting The URL: " + fulluri.ToString());
Process.Start(fulluri.ToString());
StringBuilder sb = new StringBuilder();
XmlReader readesr = XmlReader.Create(fulluri.ToString());
MessageBox.Show("REading data from " + fulluri.ToString());
while (readesr.Read())
{
sb.AppendLine(readesr.ReadOuterXml());
}
string XMLs = sb.ToString();
XML = XMLs;
MessageBox.Show("XML : " + XML);
GetXMLStuff();
}
public void GetXMLStuff()
{
tcplistener.Stop();
XmlDocument doc = new XmlDocument();
doc.LoadXml(XML);
XmlNodeList nodes = doc.DocumentElement.SelectNodes("/ISBNdb/BookList");
List<Book> books = new List<Book>();
foreach (XmlNode node in nodes)
{
Book book = new Book();
try
{
if (node.SelectSingleNode("BookData/AuthorsText").InnerText == null)
{
MessageBox.Show("Could not find this book. Please enter data by hand.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBarcode.Clear();
return;
}
}
catch
{
MessageBox.Show("Could not find this book. Please enter data by hand.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// textBarcode.Clear();
return;
}
book.author = node.SelectSingleNode("BookData/AuthorsText").InnerText;
book.title = node.SelectSingleNode("BookData/Title").InnerText;
book.ISBN = node.SelectSingleNode("BookData").Attributes["isbn"].Value;
books.Add(book);
MessageBox.Show(book.author);
addInfo(book.author, book.title, book.ISBN);
textBarcode.Clear();
}
// MessageBox.Show("Total books: " + books.Count);
}
private void addInfo(string Author, string Title, string ISBN)
{
textAuthor.Text = Author;
textTitle.Text = Title;
textISBN.Text = ISBN;
}
class Book
{
public string ISBN;
public string title;
public string author;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
int time = 10;
bool cancel = false;
private void timer1_Tick(object sender, EventArgs e)
{
if(time > 0)
{
labelTime.Text = time.ToString();
button1.Text = "Change Data";
cancel = true;
labelTime.Visible = true;
time--;
// MessageBox.Show(time.ToString());
}
if(time <= 0)
{
cancel = false;
button1.Text = "Add to List";
timer1.Stop();
time = 10;
labelTime.Visible = false;
MessageBox.Show("Submitting");
}
}
private void button1_Click(object sender, EventArgs e)
{
if(cancel)
{
timer1.Stop();
labelTime.Visible = false;
time = 10;
cancel = false;
button1.Text = "Add to List";
}
else
{
timer1.Start();
}
}
private void button2_Click(object sender, EventArgs e)
{
Thread tcpServer = new Thread(new ParameterizedThreadStart(TCPServerRun));
//TCPServerRun();
tcpServer.Start();
}
bool on = true;
TcpListener tcplistener = new TcpListener(IPAddress.Any, 5004);
private void TCPServerRun(object test)
{
try
{
MessageBox.Show("Starting Listener");
tcplistener.Start();
}
catch { MessageBox.Show("COULDNT START TPCSERVER"); return; }
while (on == true)
{
try
{
TcpClient client = tcplistener.AcceptTcpClient();
Thread tcpHandlerThread = new Thread(new ParameterizedThreadStart(tcpHandler));
// tcpHandlerThread.Start(client);
tcpHandler(client);
}
catch
{
tcplistener.Stop();
// MessageBox.Show("Stopping Listener");
}
}
}
string bCode = "";
private void tcpHandler(object client)
{
TcpClient mClient = (TcpClient)client;
NetworkStream stream = mClient.GetStream();
byte[] message = new byte[1024];
stream.Read(message, 0, message.Length);
bCode = Encoding.ASCII.GetString(message);
stream.Close();
mClient.Close();
MessageBox.Show(bCode);
this.textBarcode.Text = bCode;
GetXMLBarcodeData();
}
}
}
Possible Hint: Could it have something to do with how I have threads working?
*Edit: * **I have updated the code to have the barcode be put in a textBox and then used to fetch the data. This does not seem to work either because it 'Cannot access the control on a thread other than on which it was created'
If manual user input succeed while automated input fail, the simplest hack is just replacing the automated input to a call to manual control BeginInvoke. For your code this would be :
textBarcode.BeginInvoke(new Action(() => {
textBarcode.Text = bCode;
GetXMLBarcodeData();
}));
I'm basically making a mass email sender in C# using Microsoft Visual Studio, the idea is that it uses real email accounts via SMTP to send the emails so they are not marked as spam, but I keep getting the error:
URI formats are not supported.
Basically the code below retrieves the list of email accounts from my website but throws the error above.
String[] saUsernames = File.ReadAllLines(#"http://mywebsite.com/test/accounts.txt");
I've tried loading the file locally and it works fine so i cant figure out what the issue is, anyone got any ideas as I'm well and truly confused
edit: heres the whole script as something else may be causing the error, ive removed some of the links to my site,etc as its a project in development and i dont want to give away many clues
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using System.Threading;
using System.IO;
namespace NecroBomber
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int iTimeOutValue = 100;
int iSentAmount = 0;
SmtpClient client = new SmtpClient();
MailMessage mail = new MailMessage();
String[] saUsernames = File.ReadAllLines(#"http://example.com/accounts.txt");
WebClient wcUpdates = new WebClient();
string sMasterPassword = "testpassword";
string sLastUsername = "";
int iTimeOutWebRequest = 0;
private void btnClick(object sender, EventArgs e)
{
Button btnCurrent = ((Button)sender);
if (btnCurrent.Tag.ToString() == "SendMail")
{
prbSentStatus.Maximum = ((int)nudAmount.Value * saUsernames.Length);
Thread tStart = new Thread(SendMail);
tStart.Start();
}
else if (btnCurrent.Tag.ToString() == "AddAccount")
{
AddNewAccount();
}
else if (btnCurrent.Tag.ToString() == "Update")
{
try
{
if (wcUpdates.DownloadString(#"http://example.com/version.txt") != "1.0.0")
{
if (dlgSaveUpdate.ShowDialog() == DialogResult.OK)
{
wcUpdates.DownloadFile(#"http://example.com/new.exe", dlgSaveUpdate.FileName);
}
}
else
{
MessageBox.Show("Your version is up to date!", "Information!");
}
}
catch
{
}
}
}
private void SendMail()
{
int iToSend = Convert.ToInt32(nudAmount.Value);
for (int i = 0; i < saUsernames.Length; i++)
{
GrabMailDetails(i);
client.Credentials = new NetworkCredential(saUsernames[i], sMasterPassword);
if (saUsernames[i] != sLastUsername)
{
if (saUsernames[i].EndsWith("#yahoo.com"))
{
client.Host = "smtp.mail.yahoo.com";
client.Port = 587;
client.EnableSsl = false;
}
else if (saUsernames[i].EndsWith("#gmail.com"))
{
client.Host = "smtp.gmail.com";
client.Port = 25;
client.EnableSsl = true;
}
else if (saUsernames[i].EndsWith("#hotmail.co.uk"))
{
client.Host = "smtp.live.com";
client.Port = 587;
client.EnableSsl = true;
}
else if (saUsernames[i].EndsWith("#outlook.com"))
{
client.Host = "smtp.live.com";
client.Port = 587;
client.EnableSsl = true;
}
else if (saUsernames[i].EndsWith("#hotmail.com"))
{
client.Host = "smtp.live.com";
client.Port = 587;
client.EnableSsl = true;
}
else if (saUsernames[i].EndsWith("#aol.co.uk"))
{
client.Host = "smtp.aol.com";
client.Port = 587;
client.EnableSsl = true;
}
else if (saUsernames[i].EndsWith("#aol.com"))
{
client.Host = "smtp.aol.com";
client.Port = 587;
client.EnableSsl = true;
}
}
else
{
}
sLastUsername = saUsernames[i];
for (int x = 0; x < iToSend; x++)
{
try
{
client.Send(mail);
iSentAmount++;
}
catch
{
MessageBox.Show("Maximum emails today sent from this SMTP server has been reached.\nAccount name: " + sLastUsername, "Error!");
goto JMP;
}
}
JMP: ;
}
}
private void GrabMailDetails(int count)
{
try
{
mail = new MailMessage();
mail.Body = tbBody.Text;
mail.Subject = tbSubject.Text;
mail.From = new MailAddress(saUsernames[count]);
mail.To.Add(tbTarget.Text);
{
}
if (rbHigh.Checked)
{
mail.Priority = MailPriority.High;
}
else if (rbLow.Checked)
{
mail.Priority = MailPriority.Low;
}
else if (rbNorm.Checked)
{
mail.Priority = MailPriority.Normal;
}
}
catch
{
}
}
private void AddNewAccount()
{
String[] saCurrentAccounts = File.ReadAllLines(#"Accounts.txt");
string sAddNewAccount = "";
for (int i = 0; i < saCurrentAccounts.Length; i++)
{
sAddNewAccount += saCurrentAccounts[i] + Environment.NewLine;
}
}
private void timeUpdate_Tick(object sender, EventArgs e)
{
prbSentStatus.Value = iSentAmount;
lblEmailSentCount.Text = "Emails Sent: " + iSentAmount;
iTimeOutWebRequest++;
if (iTimeOutWebRequest == iTimeOutValue)
{
}
}
private void Form1_Load(object sender, EventArgs e)
{
timeUpdate.Start();
lblMultiple.Text = "x " + saUsernames.Length;
this.Text = "test - " + Environment.UserName;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
if (wcUpdates.DownloadString(#"update.com/version") != "1.0.0")
{
if (dlgSaveUpdate.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("Updating LulzBomber. Please wait a few minutes", "Information!");
wcUpdates.DownloadFile(#"update.com/version", dlgSaveUpdate.FileName);
}
}
else
{
MessageBox.Show("Your version is up to date!", "Information!");
}
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show("Created by ***", "About");
}
}
}
File.ReadAllLines does not support the http schema such as http.
Try instead:
string content;
using (WebClient client = new WebClient())
{
content = client.DownloadString("http://example.com/accounts.txt");
}
'content' will contain the complete contents of the file. Splitting the content into an array is trivial using the string.Split() function.
Note: WebClient can also reference local files from disk if referenced as such:
#"file://c:\folder\account.txt"
File.ReadAllLines does not support a direct URI path as stated in the error message (although it is puzzling how it is working locally), just allocate your path to a string then use that in the request.
string path = #"http://mywebsite.com/test/accounts.txt";
String[] saUsernames = File.ReadAllLines(path);
Edit: You could ditch the # as there are no characters to escape in your string and just use your original line.