# Path Questions StreamReader??

This is a discussion on Path Questions StreamReader?? within the C# Programming forums, part of the General Programming Boards category; Hello, I'm reading a file from a network drive but I'm having a problem in this line. Code: StreamReader fileRead ...

1. ## Path Questions StreamReader??

Hello,

I'm reading a file from a network drive but I'm having a problem in this line.
Code:
StreamReader fileRead = new StreamReader("\\E-Storage\\Billing\\text.txt")
The reason that I don't specify the drive is because I will be reading a file from a network drive which sometimes could be map to different drive letters.

My question is how should I write the path then

Code:
("\\E-Storage\\Billing\\text.txt") or
(@"\E-Storage\Billing\text.txt")
I tried both and program did not work however when I specified a letter such as c:\text.txt it works fine so could you correct me if I'm wrong.

Thank you

2. I'm far from being sure about this, but I think you might try it though:

"%root%\\E-Storage\\Billing\\text.txt"

I think I've seen this somewhere = /

3. This worked for me:
Code:
(@"\\Bdonaldsondev\documentation\bgd3.txt") or
("\\\\Bdonaldsondev\\documentation\\bgd3.txt")
Remember that you need two slashes on the beginning for network paths, not one.

Popular pages Recent additions