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 チェックシステム40 { internal partial class Form1 : Form { internal Form1() { InitializeComponent(); //string[] myString; //myString = new string[10]; FileSystemWatcher watcher = new FileSystemWatcher(); //watcher.Path = @"C:\Users\naomi\Desktop\有岡ファイル更新テスト\";//C:\Users\naomi\Desktop 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.SynchronizingObject = this; watcher.EnableRaisingEvents = true; // Console.Read(); // キー入力があるまで待つ //this.label1.Text = ""; //MessageBox.Show("キー入力だよ "); } internal void DoWork(object source, FileSystemEventArgs e) { //MessageBox.Show("Do Work実行 "); //this.label1.Text = "asdasdasdasd"; Console.WriteLine(e.ChangeType.ToString()); Console.WriteLine(e.FullPath); //FileInfoオブジェクトを作成 //System.IO.FileInfo fi = new System.IO.FileInfo(@"C:\Users\naomi\Desktop\有岡ファイル更新テスト\有岡テスト010.txt"); System.IO.FileInfo fi = new System.IO.FileInfo(@"C:\Documents and Settings\housya4\デスクトップ\有岡ファイル更新テスト\有岡テスト010.txt"); //C:\test.txt を C:\test1.txt にコピー //fi.CopyTo(@"C:\Users\naomi\Desktop\B有岡ファイル更新テスト\有岡テスト010.txt", true); 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(); //string myString; string[] myString; myString = new string[10]; StreamReader mySR = new StreamReader(@"C:\Documents and Settings\housya4\デスクトップ\B有岡ファイル更新テスト\有岡テスト010.txt", System.Text.Encoding.Default); //StreamReader mySR // = new StreamReader(@"C:\Users\naomi\Desktop\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(); } } }