开发者

How do I use FileOpen (VB.NET) in C#? How do I convert this code?

So, I'm working 开发者_运维问答on converting this code from VB.NET to C#:

FileOpen(1, Application.StartupPath & "\Stub.exe", _
    OpenMode.Binary, OpenAccess.Read, OpenShare.Default)

I've used a series of online converters, and they don't really work for me.

How do I do it? I'm trying to understand VB.NET source code so I can use it in.


Use the following code.

BinaryReader br =
    new BinaryReader(
        new FileStream(Application.StartupPath + "/stub.exe",
        FileMode.Open,
        FileAccess.Read,
        FileShare.Read));


The best solution is to redevelop the code using a BinaryReader.

If there's a lot of code and you are pressed for time, you could import Microsoft.VisualBasic into your C# project and then use Microsoft.VisualBasic.FileOpen.


Look at the documentation. There are C# examples provided.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜