您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

31 行
829 B

using System.IO;
using UnityEngine;
namespace ParrelSync
{
public class FileUtilities : MonoBehaviour
{
public static bool IsFileLocked(string path)
{
FileInfo file = new FileInfo(path);
try
{
using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None))
{
stream.Close();
}
}
catch (IOException)
{
//the file is unavailable because it is:
//still being written to
//or being processed by another thread
//or does not exist (has already been processed)
return true;
}
//file is not locked
return false;
}
}
}