FileStream.Unlock メソッド
他のプロセスにより以前にロックされたファイルの全部または一部へのアクセスを許可します。
Public Overridable Sub Unlock( _
ByVal position As Long, _ ByVal length As Long _)
[C#]
public virtual void Unlock(longposition,longlength);
[C++]
public: virtual void Unlock(__int64position,__int64length);
[JScript]
public function Unlock(
position : long,length : long);
パラメータ
- position
ロックを解除する範囲の先頭。 - length
ロックを解除する範囲。
例外
例外の種類 | 条件 |
---|---|
ArgumentOutOfRangeException | position または length が負の値です。 |
解説
その他の一般的な I/O タスクまたは関連する I/O タスクの例を次の表に示します。
実行するタスク | 参考例があるトピック |
---|---|
テキスト ファイルを作成する。 | ファイルへのテキストの書き込み |
テキスト ファイルに書き込む。 | ファイルへのテキストの書き込み |
テキスト ファイルから読み取る。 | ファイルからのテキストの読み取り |
テキストをファイルに追加する。 | ログ ファイルのオープンと追加 |
ファイルの名前を変更、またはファイルを移動する。 | File.Move |
ファイルをコピーする。 | File.Copy |
ディレクトリのサイズを取得する。 | FileInfo.Length |
ファイルの属性を取得する。 | File.GetAttributes |
ファイルの属性を設定する。 | File.SetAttributes |
サブディレクトリを作成する。 | CreateSubdirectory |
バイナリ ファイルから読み取る。 | 新しく作成したデータ ファイルの読み取りと書き込み |
バイナリ ファイルに書き込む。 | 新しく作成したデータ ファイルの読み取りと書き込み |
ディレクトリ内のファイルを参照する。 | Name |
ディレクトリ内のファイルをサイズ順に並べ替える。 | GetFileSystemInfos |
使用例
[Visual Basic, C#, C++] 次のコード例は Lock メソッドの例の一部です。
' Unlock the specified part of the file.
Case "U"C
Try
aFileStream.Unlock( _
textLength - 1, byteCount)
Console.WriteLine("The specified part " & _
"of file has been unlocked.")
Catch ex As IOException
Console.WriteLine( _
"{0}: The specified part of file " & _
"is not locked by the current " & _
"process.", ex.GetType().Name)
End Try
Exit Select
[C#]
// Unlock the specified part of the file.
case 'U':
try
{
fileStream.Unlock(
textLength - 1, byteCount);
Console.WriteLine("The specified part " +
"of file has been unlocked.");
}
catch(IOException e)
{
Console.WriteLine(
"{0}: The specified part of file is " +
"not locked by the current process.",
e.GetType().Name);
}
break;
[C++]
// Unlock the specified part of the file.
case 'U':
try
{
fileStream->Unlock(
textLength - 1, byteCount);
Console::WriteLine(S"The specified part "
S"of file has been unlocked.");
}
catch(IOException* e)
{
Console::WriteLine(
S"{0}: The specified part of file is "
S"not locked by the current process.",
e->GetType()->Name);
}
break;
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
FileStream クラス | FileStream メンバ | System.IO 名前空間 | 入出力操作 | ファイルからのテキストの読み取り | ファイルへのテキストの書き込み