FileStream.Name プロパティ

定義

FileStream で開かれているファイルの絶対パスを取得します。Gets the absolute path of the file opened in the FileStream.

public:
 virtual property System::String ^ Name { System::String ^ get(); };
public virtual string Name { get; }
member this.Name : string
Public Overridable ReadOnly Property Name As String

プロパティ値

ファイルの絶対パスを表す文字列。A string that is the absolute path of the file.

このコード例は、FileStream(String, FileMode, FileAccess, FileShare, Int32, Boolean) コンストラクター用に用意されている、より大きな例の一部です。This code example is part of a larger example provided for the FileStream(String, FileMode, FileAccess, FileShare, Int32, Boolean) constructor.

   static void EndReadCallback( IAsyncResult^ asyncResult )
   {
      State^ tempState = dynamic_cast<State^>(asyncResult->AsyncState);
      int readCount = tempState->FStream->EndRead( asyncResult );
      int i = 0;
      while ( i < readCount )
      {
         if ( tempState->ReadArray[ i ] != tempState->WriteArray[ i++ ] )
         {
            Console::WriteLine( "Error writing data." );
            tempState->FStream->Close();
            return;
         }
      }

      Console::WriteLine( "The data was written to {0} "
      "and verified.", tempState->FStream->Name );
      tempState->FStream->Close();
      
      // Signal the main thread that the verification is finished.
      tempState->ManualEvent->Set();
   }


public:

static void EndReadCallback(IAsyncResult asyncResult)
{
    State tempState = (State)asyncResult.AsyncState;
    int readCount = tempState.FStream.EndRead(asyncResult);

    int i = 0;
    while(i < readCount)
    {
        if(tempState.ReadArray[i] != tempState.WriteArray[i++])
        {
            Console.WriteLine("Error writing data.");
            tempState.FStream.Close();
            return;
        }
    }
    Console.WriteLine("The data was written to {0} and verified.",
        tempState.FStream.Name);
    tempState.FStream.Close();

    // Signal the main thread that the verification is finished.
    tempState.ManualEvent.Set();
}
Private Shared Sub EndReadCallback(asyncResult As IAsyncResult)
     Dim tempState As State = _
         DirectCast(asyncResult.AsyncState, State)
     Dim readCount As Integer = _
         tempState.FStream.EndRead(asyncResult)

     Dim i As Integer = 0
     While(i < readCount)
         If(tempState.ReadArray(i) <> tempState.WriteArray(i))
             Console.WriteLine("Error writing data.")
             tempState.FStream.Close()
             Return
         End If
         i += 1
     End While

     Console.WriteLine("The data was written to {0} and " & _
         "verified.", tempState.FStream.Name)
     tempState.FStream.Close()

     ' Signal the main thread that the verification is finished.
     tempState.ManualEvent.Set()
 End Sub

注釈

絶対パスが不明の場合、このプロパティは "[Unknown]" に類似した文字列を返します。If the absolute path is not known, this property returns a string similar to "[Unknown]".

一般的なファイルおよびディレクトリ操作の一覧については、「一般的な I/o タスク」を参照してください。For a list of common file and directory operations, see Common I/O Tasks.

セキュリティ

FileIOPermission
パスへのアクセスに使用します。for access to the path. 関連付けられた列挙型: PathDiscoveryAssociated enumeration: PathDiscovery

適用対象

こちらもご覧ください