您好我想创建一个连接到我的主机的应用程序并检查目录中是否添加了任何新文件。所以我需要该主机文件的创建时间,但我无法连接到服务器。我只是找到了一些用于创建服务器文件的代码,但我不知道为什么它们不能以某种方式工作。有什么建议吗?
这是代码:
string path = "http://neginmelk.ir/app_test\t2/mine.txt";
if (!File.Exists(path))
{
File.Create(path);
}
else
{
// Take an action that will affect the write time.
File.SetLastWriteTime(path, new DateTime(1985,4,3));
}
// Get the creation time of a well-known directory.
DateTime dt = File.GetLastWriteTime(path);
Console.WriteLine("The last write time for this file was {0}.", dt);
// Update the last write time.
File.SetLastWriteTime(path, DateTime.Now);
dt = File.GetLastWriteTime(path);
Console.WriteLine("The last write time for this file was {0}.", dt);