本文整理汇总了C#中System.IO.FileInfo.IsFileLocked方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.IsFileLocked方法的具体用法?C# FileInfo.IsFileLocked怎么用?C# FileInfo.IsFileLocked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.IsFileLocked方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public static Map Read(string file)
{
if (!File.Exists(file))
{
Write(file, new Map());
return new Map();
}
else
{
FileInfo inf = new FileInfo(file);
while (inf.IsFileLocked()) { Console.WriteLine("Wait..."); };
try
{
using (Stream s = File.Open(file, FileMode.Open))
{
System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(Map));
return (Map)reader.Deserialize(s);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.GetBaseException().ToString());
return new Map();
}
}
}
示例2: checkFileFunctionThread
private void checkFileFunctionThread(object obj)
{
while (true)
{
if (setting.DateFile > 0)
{
List<string> fileRecord = Directory.GetFiles(setting.Folder, "*.mp4", SearchOption.AllDirectories).ToList();
if (fileRecord != null && fileRecord.Count > 0)
{
foreach (string file in fileRecord)
{
FileInfo inf = new FileInfo(file);
if (inf.Exists && inf.CreationTime.Date < DateTime.Now.Date)
{
double day = (DateTime.Now.Date - inf.CreationTime.Date).TotalDays;
if (day > setting.DateFile && !inf.IsFileLocked())
{
inf.Delete();
}
}
}
}
}
Thread.Sleep(24 * 3600 * 1000);
}
}
示例3: Cleanup
protected override void Cleanup()
{
base.Cleanup();
var fi = new FileInfo(_testName + ".database.catIndex.location");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
}
示例4: Cleanup
void Cleanup()
{
var fi = new FileInfo(_testName + ".database");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
}
示例5: Cleanup
protected virtual void Cleanup()
{
var fi = new FileInfo(_testName + ".xml");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".index");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".test.index");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".database");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".database.index");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".subscriber.database");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".subscriber.database.index");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".subscriber.database");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".subscriber.database.index");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".catalog.indexUpdate");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".scenario");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".database.catIndex.index");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
fi = new FileInfo(_testName + ".database.cascade.index");
if (fi.Exists)
while (fi.IsFileLocked())
Thread.Sleep(100);
fi.Delete();
}