File is not the write context in c# what would be the syntax
file.Open(1, Server.MapPath("\DBP.txt"), OpenMode.Input, OpenAccess.Read, OpenShare.Shared);
Even in VB, FileOpen is not the recommended way to work. You will have to learn to work with streams.
There are many streams in .NET (FileStream, StreamReader, StreamWriter, StringWriter, StringReader, binary streams, XML streams), you might need to find the one that suits you the best. And in some situations, they need to be used in combination.
The one that is used most often to read text files is the StreamReader:
VB
Dim yourFile As New IO.StreamReader("\DBP.txt")Dim line As Stringline = yourFile.ReadLine
No need to pass the other parameters, the role of the StreamReader being to read files, it opens by default with those conditions. That is why .NET has many streams, each one is specialized, so they are easier to open and to work with than the old ways.
ReadLine is one of the many methods you can use to read with a StreamReader, so explorer the other ones. Note that the norion of EOF (EndOfFile) has been replaced by the EndOfStream property of the Stream.
And also be aware than in C#, the backslash has a special meaning, so you need to use a double one where you used only one in VB.
There are many streams in .NET (FileStream, StreamReader, StreamWriter, StringWriter, StringReader, binary streams, XML streams), you might need to find the one that suits you the best. And in some situations, they need to be used in combination.
The one that is used most often to read text files is the StreamReader:
VB
Open in new window
C#Open in new window
No need to pass the other parameters, the role of the StreamReader being to read files, it opens by default with those conditions. That is why .NET has many streams, each one is specialized, so they are easier to open and to work with than the old ways.ReadLine is one of the many methods you can use to read with a StreamReader, so explorer the other ones. Note that the norion of EOF (EndOfFile) has been replaced by the EndOfStream property of the Stream.
And also be aware than in C#, the backslash has a special meaning, so you need to use a double one where you used only one in VB.