本文整理汇总了C#中System.IO.StreamReader.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.CopyTo方法的具体用法?C# StreamReader.CopyTo怎么用?C# StreamReader.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了StreamReader.CopyTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
this.SetContentView(IslamicHadithAND.Resource.Layout.Book);
//ActionBar
ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
progress = ProgressDialog.Show(this, "انتظر من فضلك", "يتم تحميل الأحاديث ...", true);
new Thread(new ThreadStart(() =>
{
Thread.Sleep(1);
this.RunOnUiThread(() =>
{
try
{
string content;
using (StreamReader streamReader = new StreamReader(Assets.Open("hadeeth.sqlite")))
{
content = streamReader.ReadToEnd();
}
string dbName = "hadeeth.sqlite";
string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName);
if (!File.Exists(dbPath))
{
using (Stream source = new StreamReader(Assets.Open("hadeeth.sqlite")).BaseStream)
{
using (var destination = System.IO.File.Create(dbPath))
{
source.CopyTo(destination);
}
}
}
DataTable dataTableBook = new DataTable();
var connectionString = string.Format("Data Source={0};Version=3;", dbPath);
using (var conn = new SqliteConnection((connectionString)))
{
using (var command = conn.CreateCommand())
{
conn.Open();
command.CommandText = @"SELECT hadeeth.*" +
"FROM Books INNER JOIN hadeeth ON Books.ID = hadeeth.BID" +
" where hadeeth.hadeeth like '%<%' and " +
"books.title like '%سنن الدارمي%'";
command.CommandType = CommandType.Text;
SqliteDataAdapter dataAdapter = new SqliteDataAdapter();
dataAdapter.SelectCommand = command;
dataAdapter.Fill(dataTableBook);
}
}
var data = new List<string>();
for (int i = 0; i < dataTableBook.Rows.Count; i++)
{
data.Add(unBold((dataTableBook.Rows[i]["hadeeth"].ToString())));
if (dataTableBook.Rows.Count == 0)
{
new AlertDialog.Builder(this)
.SetTitle("خطأ")
.SetMessage("لا يوجد نتائج")
.SetPositiveButton("عودة", (senderaa, args) =>
{
// Back
})
.Show();
}
}
var listView = FindViewById<ListView>(IslamicHadithAND.Resource.Id.listBook);
listView.Adapter = new ArrayAdapter(this, Resource.Layout.ListViewContents, data);
listView.ItemClick += (sender, e) =>
{
var position = e.Position;
var HadithBrowser = new Intent(this, typeof(HadithBrowser));
HadithBrowser.PutExtra("Hadith", listView.GetItemAtPosition(position).ToString());
if (!listView.GetItemAtPosition(position + 1).Equals(null))
{
position++;
HadithBrowser.PutExtra("HadithNext1", listView.GetItemAtPosition(position).ToString());
}
if (!listView.GetItemAtPosition(position - 1).Equals(null))
{
position--;
HadithBrowser.PutExtra("HadithPrevious1", listView.GetItemAtPosition(position).ToString());
}
StartActivity(HadithBrowser);
};
}
catch (Exception ex)
{
new AlertDialog.Builder(this)
.SetPositiveButton("عودة", (sendera, args) =>
{
// Back
})
//.........这里部分代码省略.........
示例2: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.SearchByAuthor);
//ActionBar
ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
var btnSearchByAuthorData = FindViewById<Button>(Resource.Id.btnSearchByAuthorData);
var txtKeywordAuthor = FindViewById<EditText>(Resource.Id.txtKeywordAuthor);
var spinnerAuthorName = FindViewById<Spinner>(Resource.Id.txtAuthorNameData);
spinnerAuthorName.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinnerAuthorName_ItemSelected);
var adapter = ArrayAdapter.CreateFromResource(
this, Resource.Array.AuthorsNames, Android.Resource.Layout.SimpleSpinnerItem);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinnerAuthorName.Adapter = adapter;
btnSearchByAuthorData.Click += delegate
{
progress = ProgressDialog.Show(this, "انتظر من فضلك", "يتم تحميل الأحاديث ...", true);
new Thread(new ThreadStart(() =>
{
Thread.Sleep(1);
this.RunOnUiThread(() =>
{
try
{
string content;
using (StreamReader streamReader = new StreamReader(Assets.Open("hadeeth.sqlite")))
{
content = streamReader.ReadToEnd();
}
string dbName = "hadeeth.sqlite";
string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName);
if (!File.Exists(dbPath))
{
using (Stream source = new StreamReader(Assets.Open("hadeeth.sqlite")).BaseStream)
{
using (var destination = System.IO.File.Create(dbPath))
{
source.CopyTo(destination);
}
}
}
DataTable dataTable = new DataTable();
var connectionString = string.Format("Data Source={0};Version=3;", dbPath);
using (var sqliteConnection = new SqliteConnection((connectionString)))
{
using (var command = sqliteConnection.CreateCommand())
{
sqliteConnection.Open();
command.CommandText = @"SELECT hadeeth.* " +
"FROM (authors INNER JOIN books ON authors.ID = Books.Author) " +
"INNER JOIN hadeeth ON Books.ID = hadeeth.BID " +
"WHERE (((authors.name) Like '%" + txtAuthorNameData.ToString() + "%') " +
"and ((hadeeth.hadeeth_norm) Like '%" + txtKeywordAuthor.Text + "%'))";
command.CommandType = CommandType.Text;
SqliteDataAdapter dataAdapter = new SqliteDataAdapter();
dataAdapter.SelectCommand = command;
dataAdapter.Fill(dataTable);
}
}
var data = new List<string>();
for (int i = 0; i < dataTable.Rows.Count; i++)
{
data.Add(unBold(dataTable.Rows[i]["hadeeth"].ToString()));
}
if (dataTable.Rows.Count == 0)
{
new AlertDialog.Builder(this)
.SetTitle("خطأ")
.SetMessage("لا يوجد نتائج")
.SetPositiveButton("عودة", (senderaa, args) =>
{
// Back
})
.Show();
}
var listView = FindViewById<ListView>(Resource.Id.listHadithByAuthor);
listView.Adapter = new ArrayAdapter(this, Resource.Layout.ListViewContents, data);
listView.ItemClick += (sender, e) =>
{
var position = e.Position;
var HadithBrowser = new Intent(this, typeof(HadithBrowser));
HadithBrowser.PutExtra("Hadith", listView.GetItemAtPosition(position).ToString());
if (!listView.GetItemAtPosition(position + 1).Equals(null))
{
position++;
HadithBrowser.PutExtra("HadithNext1", listView.GetItemAtPosition(position).ToString());
}
//.........这里部分代码省略.........
示例3: tSBExportProfile_Click
private void tSBExportProfile_Click(object sender, EventArgs e)
{
if (lBProfiles.SelectedIndex < 0)
{
return;
}
using (Stream profile = new StreamReader(Global.appdatapath + "\\Profiles\\" + lBProfiles.SelectedItem + ".xml").BaseStream)
{
if (saveProfiles.ShowDialog() != DialogResult.OK)
{
return;
}
using (Stream stream = saveProfiles.OpenFile())
{
profile.CopyTo(stream);
profile.Close();
}
}
}
示例4: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.HadithTitle);
//ActionBar
ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
progress = ProgressDialog.Show(this, "انتظر من فضلك", "يتم تحميل العناوين ...", true);
new Thread(new ThreadStart(() =>
{
Thread.Sleep(1);
this.RunOnUiThread(() =>
{
try
{
string content;
using (StreamReader streamReader = new StreamReader(Assets.Open("hadeeth.sqlite")))
{
content = streamReader.ReadToEnd();
}
string dbName = "hadeeth.sqlite";
string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbName);
if (!File.Exists(dbPath))
{
using (Stream source = new StreamReader(Assets.Open("hadeeth.sqlite")).BaseStream)
{
using (var destination = System.IO.File.Create(dbPath))
{
source.CopyTo(destination);
}
}
}
DataTable dataTableSubject = new DataTable();
DataTable dataTableHadith = new DataTable();
var connectionString = string.Format("Data Source={0};Version=3;", dbPath);
using (var sqliteConnection = new SqliteConnection((connectionString)))
{
using (var command = sqliteConnection.CreateCommand())
{
sqliteConnection.Open();
command.CommandText = @"select distinct hadeeth.title from hadeeth";
command.CommandType = CommandType.Text;
SqliteDataAdapter da = new SqliteDataAdapter();
da.SelectCommand = command;
da.Fill(dataTableSubject);
}
}
var data = new List<string>();
for (int i = 0; i < dataTableSubject.Rows.Count; i++)
{
data.Add(unBold(dataTableSubject.Rows[i]["title"].ToString()));
}
if (dataTableSubject.Rows.Count == 0)
{
new AlertDialog.Builder(this)
.SetTitle("خطأ")
.SetMessage("لا يوجد نتائج")
.SetPositiveButton("عودة", (senderaa, args) =>
{
// Back
})
.Show();
}
var listView = FindViewById<ListView>(Resource.Id.listHadithTitle);
listView.Adapter = new ArrayAdapter(this, Resource.Layout.ListViewContents, data);
listView.ItemClick += (sender, e) =>
{
progress = ProgressDialog.Show(this, "انتظر من فضلك", "يتم تحميل الموضوعات ...", true);
new Thread(new ThreadStart(() =>
{
Thread.Sleep(1);
this.RunOnUiThread(() =>
{
var connectionString2 = string.Format("Data Source={0};Version=3;", dbPath);
using (var conn2 = new SqliteConnection((connectionString2)))
{
using (var command = conn2.CreateCommand())
{
conn2.Open();
command.CommandText = @"SELECT hadeeth.* " +
"FROM hadeeth WHERE " +
"(((hadeeth.title) Like '%" + listView.GetItemAtPosition(e.Position).ToString() + "%'))";
command.CommandType = CommandType.Text;
SqliteDataAdapter da2 = new SqliteDataAdapter();
da2.SelectCommand = command;
da2.Fill(dataTableHadith);
}
}
//.........这里部分代码省略.........