In C#, how do you grab the name or path of the streamreader
ie
filein = new StreamReader(@"C:\ee\fff\Desktop\spreadtool\test.csv");
and now I want to regex on the path, how do I reference the above. I know filestreamer has a getname() method but does streamreader? I looked it up and it doesn't seem to have one.
StreamReader does not have a property that contains the FilePath from which it was created. It may not be created from a file at all (it can be created from a stream). If you want the path, you should store it in a string before you create the StreamReader
String file = @"C:\ee\ccc\Desktop\spreadtool\test.csv"
filein = new StreamReader(file);
String path = Path.GetDirectory(file);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With