Edit

Share via


FileStream.Name Property

Definition

Gets the absolute path of the file opened in the FileStream.

public string Name { get; }
public virtual string Name { get; }

Property Value

A string that is the absolute path of the file.

Examples

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 = (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();
}

Remarks

If the absolute path is not known, this property returns a string similar to "[Unknown]".

For a list of common file and directory operations, see Common I/O Tasks.

Applies to

See also