我有一个表file,存储的是文件名name(类型为varchar),文件类型extension(类型为varchar),文件内容content(类型为image),表file中存放了许多office文件,我将该表绑定在一个GridView上。
现在我想获取包含某些结果的文档内容,希望web显示时Gridview绑定的content字段能以普通文本方式而不是binary数据显示,并且过长的记录用省略号替换掉,有点类似于 搜索引擎的搜索,请各位大虾指点!不胜感激!

解决方案 »

  1.   

    或者简单一点,我数据库的表中 存了4个字段,id(int),name(varchar,文件名),extension(varchar,文件类型),content(image类型,文件内容)  我想根据获取的id在新窗口中打开这些文件,或者以HTML方式打开这些文件,要求能查看文件的内容,显示的不是那二进制数据。
      

  2.   

    文件内容使用nvarchar保存即可
    二进制数据要通过扩展名转为文件保存文件夹再显示
    private void getFile(byte[] content, string filePath)
            {
                string fileName = filePath;
                System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create);
                fs.Write(content, 0, content.Length);
                fs.Flush();
                fs.Close();
            }
      

  3.   

    public static void WriteAllBytes(
    string path,
    byte[] bytes
    )