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 放射線科チェックシステム30 { internal partial class Form1 : Form { internal Form1() { InitializeComponent(); // textBox1.Text = "アイウエオ";//textBox1 FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = @"C:\Documents and Settings\housya4\デスクトップ\有岡ファイル更新テスト";//C:\Users\naomi\Desktop watcher.Filter = "*.txt";// watcher.IncludeSubdirectories = false; // watcher.NotifyFilter = NotifyFilters.FileName; watcher.Created += new FileSystemEventHandler(DoWork); // watcher.Deleted += new FileSystemEventHandler(DoWork); watcher.EnableRaisingEvents = true; // Console.Read(); // キー入力があるまで待つ MessageBox.Show("キー入力だよ "); } internal void DoWork(object source, FileSystemEventArgs e) { MessageBox.Show("Do Work実行 "); //label1.Text = "アイウエオ";//textBox1 label1.Text = "アイウエオ";//textBox1 Console.WriteLine(e.ChangeType.ToString()); Console.WriteLine(e.FullPath); //FileInfoオブジェクトを作成 System.IO.FileInfo fi = new System.IO.FileInfo(@"C:\Documents and Settings\housya4\デスクトップ\有岡ファイル更新テスト\有岡テスト010.txt"); //C:\test.txt を C:\test1.txt にコピー fi.CopyTo(@"C:\Documents and Settings\housya4\デスクトップ\B有岡ファイル更新テスト\有岡テスト010.txt", true); //C:\test.txt を C:\test1.txt に移動 //fi.MoveTo(@"C:\test1.txt"); //C:\test.txt を削除 fi.Delete(); } private void button1_Click(object sender, EventArgs e) { string myString; StreamReader mySR = new StreamReader(@"C:\Documents and Settings\housya4\デスクトップ\B有岡ファイル更新テスト\有岡テスト010.txt", System.Text.Encoding.Default); myString = mySR.ReadLine(); while (myString != null) { this.dataGridView1.Rows.Add(myString); //this.dataGridView1.Rows.Add(myArray); // this.dataGridViewTextBoxColumn Column1(myString); // myString = mySR.ReadLine(); } mySR.Close(); } } }