StreamReader openfile
вынести за пределы метода, но почему-то программа останавливается просто не доходя до конца файла и не выскакивает никаких ошибок. string query = String.Format(@"SELECT server,port,ssl FROM imap WHERE host = '{0}'", _login[1]);
SqlConnection sqlConnection = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\mailgraber.mdf;Integrated Security=True");
SqlCommand cmd = new SqlCommand(); //sql запрос
SqlDataReader reader;
sqlConnection.Open();
cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection;
reader = cmd.ExecuteReader();
private void Start()
{
StreamReader openfile = new StreamReader(openFileDialog.FileName);
while (true)
{
int current; string temp = null;
lock (block)
{
if (now < count)
{
current = now;
for (int i = 0; i <= current; i++)//работа с файлом лучшего способа не нашел.
{
//openfile.BaseStream.Seek(offset, SeekOrigin.Begin);
temp = openfile.ReadLine();
// offset += temp.Length+1;
// openfile.Dispose();
}
now++;
}
else return;
}
string login = null, pass = null;
string[] _login = null;
try
{
login = temp.Split(delimiter.Text[0])[0];
pass = temp.Split(delimiter.Text[0])[1];
_login = login.Split('@');
}
catch { continue; }
string hostname = null; int port = 993; bool ssl = true;
string query = String.Format(@"SELECT server,port,ssl FROM imap WHERE host = '{0}'", _login[1]);
SqlConnection sqlConnection = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\mailgraber.mdf;Integrated Security=True");
SqlCommand cmd = new SqlCommand(); //sql запрос
SqlDataReader reader;
sqlConnection.Open();
cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection;
reader = cmd.ExecuteReader();
....
StreamReader openfile = new StreamReader(openFileDialog.FileName);
using (var openfile = new StreamReader(openFileDialog.FileName))