<wa****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a function which gets passed a streamreader object as an
argument (I know this might sound a little weird, but it's to avoid
code repetition). My problem is this - given a streamreader object is
it possible to determine the file path the streamreader is referencing?
Only if the StreamReader is reading a FileStream:
private string GetFileName(StreamReader reader) {
FileStream fileStream = reader.BaseStream as FileStream;
if(fileStream != null) {
return fileStream.Name;
} else {
// Handle no file situation
}
}