从数据库中读出RTF格式的数据利用http://topic.csdn.net/u/20081223/16/410d78ec-2d99-42b4-be7d-a38911240d05.html贴中所示方法(以下代码有修改)string _RtfText=rtf;//rtf为数据库中读出RTF类型数据
IList<string> _ImageList =new List<string>();
while(true)
{
int _Index = _RtfText.IndexOf("pichgoal");
if(_Index==-1)break;
_RtfText=_RtfText.Remove(0,_Index+8); _Index = _RtfText.IndexOf("\r\n");
int _Temp = Convert.ToInt32(_RtfText.Substring(0, _Index));
_RtfText = _RtfText.Remove(0, _Index);
_RtfText = _RtfText.Replace("\r\n", ""); _Index = _RtfText.IndexOf("}");
_ImageList.Add(_RtfText.Substring(0, _Index)); _RtfText = _RtfText.Remove(0, _Index);
} for (int i = 0; i != _ImageList.Count; i++)
{
System.IO.FileStream _File = new FileStream(Server.MapPath("~/image/") + i.ToString() + ".jpg", System.IO.FileMode.Create);
int _Count=_ImageList[i].Length/2; for (int z = 0; z != _Count; z++)
{
string _TempText=_ImageList[i][z*2].ToString()+_ImageList[i][(z*2)+1].ToString();
_File.WriteByte(Convert.ToByte(_TempText, 16));
} _File.Close();
} MessageBox.Show(_ImageList.Count.ToString());
这种方法得到的jpg图像文件在本机能被ACDSEE显示,在asp.net的设计模式下也能显示。但运行后在浏览器中却不能显示了,利用ACDSEE将其进行格式转化后的图像却不存在这个问题。请高手指点该如何解决啊!
IList<string> _ImageList =new List<string>();
while(true)
{
int _Index = _RtfText.IndexOf("pichgoal");
if(_Index==-1)break;
_RtfText=_RtfText.Remove(0,_Index+8); _Index = _RtfText.IndexOf("\r\n");
int _Temp = Convert.ToInt32(_RtfText.Substring(0, _Index));
_RtfText = _RtfText.Remove(0, _Index);
_RtfText = _RtfText.Replace("\r\n", ""); _Index = _RtfText.IndexOf("}");
_ImageList.Add(_RtfText.Substring(0, _Index)); _RtfText = _RtfText.Remove(0, _Index);
} for (int i = 0; i != _ImageList.Count; i++)
{
System.IO.FileStream _File = new FileStream(Server.MapPath("~/image/") + i.ToString() + ".jpg", System.IO.FileMode.Create);
int _Count=_ImageList[i].Length/2; for (int z = 0; z != _Count; z++)
{
string _TempText=_ImageList[i][z*2].ToString()+_ImageList[i][(z*2)+1].ToString();
_File.WriteByte(Convert.ToByte(_TempText, 16));
} _File.Close();
} MessageBox.Show(_ImageList.Count.ToString());
这种方法得到的jpg图像文件在本机能被ACDSEE显示,在asp.net的设计模式下也能显示。但运行后在浏览器中却不能显示了,利用ACDSEE将其进行格式转化后的图像却不存在这个问题。请高手指点该如何解决啊!
解决方案 »
- [求助]VB.NET环境,连接SQL数据库时提示sa登录失败,如何解决?
- 设置Cookie的问题?为什么保存不到本地?很急 以身相许了
- 在ASP.NET中,读取某个文件目录下的.TXT类型文件,将它们的名字绑定到页面中的DropDownList控件中?如何用C#实现。
- 在.net中 ,我要判断 一个字符串 不能为0,或者00,或者000 ...就是不能不能全部为 0 怎么做啊 ?????????
- DataGrid显示记录数目的问题
- 这是我的毕业设计题目(请大家看完,来帮助我下啊!)
- 如何将HTML文档转换成.exe文件,如同CHM文件格式一样,可以打开浏览!
- cas 单点登录 .net
- 一个接触ASP.NET 4个月的学生的大学生活,大家也谈谈.
- 救命:sqlserver和iis不在一台机器上,浏览网页报错“未与信任 SQL Server 连接相关联。”可sqlserver的身份验证已经是“sqlserver和wind
- 请教一下关于web开发经验
- 请问怎么对datalist控件中的某个控件进行操作
string _RtfText = tempStr;
IList<string> _ImageList = new List<string>();
while (true)
{
int _Index = _RtfText.IndexOf("pichgoal");
if (_Index == -1) break;
_RtfText = _RtfText.Remove(0, _Index + 8); _Index = _RtfText.IndexOf("\r\n");
_RtfText = _RtfText.Remove(0, _Index);
_Index = _RtfText.IndexOf("}");
_ImageList.Add(_RtfText.Substring(0, _Index).Replace("\r\n", "")); _RtfText = _RtfText.Remove(0, _Index); }
Byte[] buffer;
buffer = null;
for (int i = 0; i != _ImageList.Count; i++)
{
// System.IO.FileStream _File = new FileStream(Server.MapPath("~/image/") + i.ToString() + ".png", System.IO.FileMode.Create);
int _Count = _ImageList[i].Length / 2;
buffer = new Byte[_ImageList[i].Length/2]; for (int z = 0; z != _Count; z++)
{
string _TempText = _ImageList[i][z * 2].ToString() + _ImageList[i][(z * 2) + 1].ToString();
// _File.WriteByte(Convert.ToByte(_TempText, 16));
buffer[z] = Convert.ToByte(_TempText, 16);
} // _File.Close();
}
MemoryStream ms = new MemoryStream(buffer);
Image _a = Image.FromStream(ms);
_a.Save(Server.MapPath("~/image/") + i.ToString() + ".png");
// Bitmap _a = new Bitmap(Application.StartupPath + "\\" + "0.dat");