FileOpen Alternative? [英] FileOpen Alternative ?

查看:86
本文介绍了FileOpen Alternative?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要更改我的代码,因为我有一些问题,我需要替换FileOpen函数。

你知道我可以使用FileOpen函数吗?

我认为写作函数但我不知道如何使用它,因为我需要将一些选项导入输出(我正在制作一个构建器应用程序)。

以下是我需要替换的实际代码:



  Dim  myfile ,opt() as   string  
FileOpen( 1 ,Application.ExecutablePath,OpenMode.Binary,OpenAccess.Read,OpenShare。 Shared

myfile = Space(LOF( 1 ))

FileGet( 1 ,myfile)
FileClose ( 1
Label1.Text = opt( 1
Label2.Text = opt( 2
Label3.Text = opt( 3





如何看到我在输出文件中收到我之前在构建器中检查过的选项(opt),但是我需要另一种方法来做到这一点。

可以写线 - 文件流功能做同样的工作吗?



希望你能帮助我。

解决方案

这取决于您想要读取/写入此文件的内容和方式。在大多数情况下,这些替代方案很多:更好的二进制/文本读取器/写入器。请参阅:

http ://msdn.microsoft.com/en-us/library/system.io.streamreader%28v=vs.110%29.aspx [ ^ ],

< a href =http://msdn.microsoft.com/en-us/library/system.io.streamwriter%28v=vs.110%29.aspx> http://msdn.microsoft.com/en-us /library/system.io.streamwriter%28v=vs.110%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.io.binaryreader%28v=vs .110%29.aspx [ ^ ],

<小时EF = http://msdn.microsoft.com/en-us/library/system.io.binarywriter.aspx> http://msdn.microsoft.com/en-us/library/system.io.binarywriter。 aspx [ ^ ]。



此外,我不确定你是否真的需要直接处理文件IO。在许多情况下,使用序列化要好得多。对于这些想法:

http://en.wikipedia.org/wiki/Serialization [使用数据合同 ^ ],

http://msdn.microsoft.com/en-us/library/ ms733127%28v = vs.110%29.aspx [ ^ ]。



祝你好运,

-SA

I need to change my code because I have some problem with it, and I need a replacement for the FileOpen function.
Do you know what could I use insted of FileOpen function ?
I thinked to writeline function but I don't know how to use it, because I need to import some option into the output (I'm making a builder app based).
Here is the actual code I need to replace :

Dim myfile, opt() as string
FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)

        myfile = Space(LOF(1))

        FileGet(1, myfile)
        FileClose(1)
        Label1.Text = opt(1)
        Label2.Text = opt(2)
        Label3.Text = opt(3)



How you can see I receive in the output file the options (opt) I checked before in my builder, but I need another way to do this.
Could writeline - filestream function do same work?

Hope you can help me.

解决方案

It depends on what and how you want to read/write to/from this file. In most cases, these alternatives are much: better binary/text readers/writers. Please see:
http://msdn.microsoft.com/en-us/library/system.io.streamreader%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.streamwriter%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.binaryreader%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.io.binarywriter.aspx[^].

Besides, I'm not sure if you really need to deal with file IO directly. In many cases, using serialization is much better. For the ideas:
http://en.wikipedia.org/wiki/Serialization[^],
using data contracts: http://msdn.microsoft.com/en-us/library/ms733127%28v=vs.110%29.aspx[^].

Good luck,
—SA


这篇关于FileOpen Alternative?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆