Answer the question
In order to leave comments, you need to log in
How to open ReadOnly file?
I need to make the file open read-only
found information about it
using (TextReader reader = new StreamReader(File.OpenRead(Path.Combine(client._WorkLogFileLoc, "dump.txt")))) {
//do stuff
}
Answer the question
In order to leave comments, you need to log in
var file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using (var stream = new StreamReader(file))
{
//код
}
Everything is very simple.
just builds the path by joining two parts - the path part from client._WorkLogFileLoc and "dump.txt" .
For example, let 's say client._WorkLogFileLoc property contains "D:\some\path\to\folder", as a result we get Path.Combine("D:\some\path\to\folder", "dump.txt")
, which will give:"D:\some\path\to\folder\dump.txt"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question