获取文件夹中的创建/修改文件日期时间 [英] Get create/modified file date time in folder
问题描述
scanerio有一个文件夹,每2秒创建一个文件,现在我想要的是当文件没有创建5薄荷意味着延迟时间然后我想要警告文件没有创建
此代码是当在文件夹中创建/修改任何最后一个文件时,在控制台中显示文件日期时间,我完成了这个...
i想要的时候ev
i试试这个
我尝试过:
< pre lang =c#> public static void Main()
{
while ( true )
{
尝试
{
string path = @ C:\ Users \Administrator \ De sktop \New folder;
// if(!File.Exists(path))
// {
// File.Create(path);
// }
// else
// {
// < span class =code-comment> File.SetLastWriteTime(path,DateTime.Now);
// }
DateTime dt = File.GetLastWriteTime(path);
Console.WriteLine( 最后一次{0},dt);
// Console.ReadLine();
}
< span class =code-keyword> catch (例外e)
{
Console.WriteLine( 进程失败:{0},e.ToString());
}
}
您是否尝试过以管理员身份运行,即提升特权?
scanerio there is a folder where file is created in every 2 seconds and now i want when file is not created in 5 mint means delay time then i want alert that file not created
this code is for when any last file is create/modified in folder that file date time displayed in console and i am done with this ..
i want when ev
i try this
What I have tried:
public static void Main()
{
while (true)
{
try
{
string path = @"C:\Users\Administrator\Desktop\New folder";
//if (!File.Exists(path))
//{
// File.Create(path);
//}
//else
//{
// File.SetLastWriteTime(path, DateTime.Now);
//}
DateTime dt = File.GetLastWriteTime(path);
Console.WriteLine("the last time {0}", dt);
//Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
}
Have you tried running this as 'Administrator' ie with elevated privileges ?
这篇关于获取文件夹中的创建/修改文件日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!