3

C# で、ファイルがフォルダーに挿入されたことを知る方法。C#でこれが必要です。

4

2 に答える 2

3

このタスクを実行するには、FileSystemWatcher クラスを使用します。

ご参照ください

http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx

http://www.codeproject.com/Articles/2157/A-NET-File-System-Watcher

于 2012-09-21T07:04:32.697 に答える
0

System.IO 名前空間の File クラスの Exists メソッドを使用して、指定したファイルが存在するかどうかを確認できます。

bool System.IO.File.Exists(string path)

例:

using System;
using System.IO;

class Program
{
    static void Main()
    {
    // See if this file exists in the SAME DIRECTORY.
    if (File.Exists("TextFile1.txt"))
    {
        Console.WriteLine("The file exists.");
    }
    // See if this file exists in the C:\ directory. [Note the @]
    if (File.Exists(@"C:\tidy.exe"))
    {
        Console.WriteLine("The file exists.");
    }
    // See if this file exists in the C:\ directory [Note the '\\' part]
    bool exists = File.Exists("C:\\lost.txt");
    Console.WriteLine(exists);
    }
}
于 2012-09-21T07:05:01.917 に答える