} // read() public static bool Available(NFile file) { FileStream stream = null; try { stream = file._fi.Open(FileMode.Open, FileAccess.Read, FileShare.None); } 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); } finally { if (stream != null) { file.Dispose(); } } //file is not locked return(false); } // Available()
} // isDirectory() public NFile[] listFiles() { NFile[] output = new NFile[0]; if (isDirectory()) { List <NFile> file_list = new List <NFile>(); IEnumerable <string> items = Directory.EnumerateFileSystemEntries(_path); foreach (string item in items) { file_list.Add(new NFile(item, FileMode.Open)); } output = file_list.ToArray(); } return(output); } // listFiles()