これは、実際にファイルを読み取る前にファイルを読み取れるかどうかを確認しようとしている方法です
FileStream stream = new FileStream();
try
{
// try to open the file to check if we can access it for read
stream = File.Open(this.DataSourceFileName, FileMode.Open, FileAccess.Read);
}
catch (IOException ex)
{
return false;
}
finally
{
stream.Dispose();
}
これは正しい方法ですか?
も にFile.Open
似ていますがFile.ReadAllText
、つまり、パフォーマンスのコストは同じですか?