当前位置: 首页>>代码示例>>C#>>正文


C# StreamReader.CopyTo方法代码示例

本文整理汇总了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
                                  })
//.........这里部分代码省略.........
开发者ID:AhmedMusbah,项目名称:IslamicHadith,代码行数:101,代码来源:SonanElDarmy.cs

示例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());
                                }
//.........这里部分代码省略.........
开发者ID:AhmedMusbah,项目名称:IslamicHadith,代码行数:101,代码来源:SearchByAuthor.cs

示例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();
                }
            }
        }
开发者ID:SonicFreak94,项目名称:DS4Windows,代码行数:21,代码来源:DS4Form.cs

示例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);
                                        }
                                    }

//.........这里部分代码省略.........
开发者ID:AhmedMusbah,项目名称:IslamicHadith,代码行数:101,代码来源:HadithTitle.cs


注:本文中的System.IO.StreamReader.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。