Obtener la ruta original de FileStream


Dado un objeto System.IO.FileStream, ¿cómo puedo obtener la ruta original al archivo al que está proporcionando acceso?

Por ejemplo, en la función MyStreamHandler() a continuación, quiero recuperar la ruta del archivo que creó el FileStream:

public static void Main() 
{
    string path = @"c:\temp\MyTest.txt";
    FileStream fs = File.Create(path));

    MyStreamHandler(fs);
    MyOtherStreamHandler(fs);

    fs.Close();
    fs.Dispose();
}

private static void MyStreamHandler(FileStream fs)
{
    // Get the originating path of 'fs'
} 

private static void MyOtherStreamHandler(FileStream fs)
{
}
Author: Yuriy Faktorovich, 2009-07-22

2 answers

La propiedad Nombre de FileStream.

Véase la documentación en MSDN

 70
Author: Yuriy Faktorovich,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-21 18:09:12

Puede utilizar fs.Name para conseguir el camino.

 4
Author: cakeforcerberus,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-07-22 14:28:53