注册 登录
编程论坛 C# 论坛

“System.IO.FileStream”隐式转换为“导入导出.Filestream”

hellation 发布于 2015-04-14 17:45, 618 次点击
当我敲下这行代码:
using (Filestream filestream = File.OpenRead(odfimport.FileName))
   {  }
系统就会报错:错误    1    无法将类型“”隐式转换为“导入导出.Filestream”    C:\Users\Administrator\Documents\Visual Studio 2010\Projects\导入导出\导入导出\Form1.cs    27    44    导入导出
3 回复
#2
hkkuality2015-04-14 18:47
Filestream这个是不是需要FileStream这样写?你的这个Filestream是什么东西啊?我怎么没见过呢
#3
hellation2015-04-14 19:11
回复 2楼 hkkuality
//if (odfimport .ShowDialog ()==DialogResult .OK )
            //{
            //    using(Filestream filestream=File.OpenRead (odfimport .FileName))
            //    {
            //        using (StreamReader  streamread=new StreamReader(filestream))
            //        {
            //            string line = null;
            //            while ((line = streamread.ReadLine()) != null)
            //            {
            //                string[] strs = line.Split('|');
            //                string name = strs[0];
            //                int age = Convert.ToInt32(strs[1]);

            //                using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Db.mdf;Integrated Security=True;User Instance=True"))
            //                {
            //                    conn.Open();
            //                    using (SqlCommand cmd = conn.CreateCommand())
            //                    {
            //                         = "insert into Td(name,age)values(@name,@age)";
            //                        cmd.Parameters.Add(new SqlParameter("name", name));
            //                        cmd.Parameters.Add(new SqlParameter("age", age));
            //                        cmd.ExecuteNonQuery();
            //                    }
            //                }
            //             }

            //        }
               
            //    }


简单说就是把一个text文档按|分位符插入数据库     才开始学   感觉好难    纠结
#4
hkkuality2015-04-15 08:45
回复 3楼 hellation
我大部分是自学的,那些名词啥的我也不懂,我不会一般问度娘,查的多了,自己就了解一点了。我在我的vs里面找不到你的  Filestream  ,只有FileStream,里面的s明明是大写啊,因为你的Filestream filestream = File.OpenRead(odfimport.FileName)我在我自己这边试的时候是换成FileStream才不报错的,其他我也不太懂了,菜鸟一个。。。
1