.NET Logo
Welcome Guest Search | Active Topics | Members | Log In | Register

ช่วยดู Error ทีครับจะโชว์รูปภาพบน Gridview ครับ Options · View
birdalter
Posted: Tuesday, July 01, 2008 10:21:58 PM

Rank: มือเทพ
Groups: Member

Joined: 12/17/2007
Posts: 69

คือโค้ดมันรันได้ไม่มีปัญหาแต่พอผมเลื่อนลงไปบรรทัดอื่นๆมันก็ขึ้น Error ดังภาพครับ

นี่โค้ดครับ
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Report
{
    public partial class Form7 : Form
    {
        public Form7()
        {
            InitializeComponent();
        }
        DataSetX DS2 = new DataSetX();
        private void Form7_Load(object sender, EventArgs e)
        {
            DataTable DT2 = DS2.Tables[0];
            DirectoryInfo Dir1 = new DirectoryInfo("C:\\Images");
            foreach (FileInfo File1 in Dir1.GetFiles())
            {
                DataRow dr = DT2.NewRow();
                dr["FileName"] = File1.Name;
                dr["FileSize"] = File1.Length;
                dr["FileDate"] = File1.CreationTime;
                FileStream File2 = new FileStream(File1.FullName, FileMode.Open, FileAccess.Read);
                byte[] CurrentImage = new byte[((int)File2.Length) + 1];
                File2.Read(CurrentImage, 0, ((int)File2.Length) - 1);
                dr["Image1"] = CurrentImage;
                DT2.Rows.Add(dr);
            }
            dataGridView1.DataSource = DT2;
        }
    }
}
 

Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.


Sponsored by