Home > Net >  How to c # and vb6 random access to the file of the following code
How to c # and vb6 random access to the file of the following code

Time:10-06

Dim As Integer f '"' revised reading
F=FreeFile
The Open strmend For Random As # f Len=100
The Get # f, 3, gguangMend
Close # f
"'" '

The Open strfix For Random As # f Len=100
Get f, # 1, ghuanfix1
The Get # f, 2, gkuaifix1
The Get # f, 3, ghuanfix2
The Get # f, 4, gkuaifix2
Close # f

CodePudding user response:

Is there a vb and c # will be a great god

CodePudding user response:

.net without access to the file this way, vb.net is no corresponding writing,

There are too many alternative methods under.net, binary file reading and writing, serialization, sqlite database is very convenient

CodePudding user response:

The so-called random read the file
Is the Seek function file
Orientation to a certain position began to read and write
Commonly used FileStream can support

CodePudding user response:

The
reference 3 floor stherix response:
the so-called random reads files
Is the Seek function file
Orientation to a certain position began to read and write
Commonly used FileStream can support
FileStream detailed how to use

CodePudding user response:

 public class Test 
{
The public Test ()
{
Var fileStream=File. OpenWrite (" path ");

//set to the location of the current flow
FileStream. Seek (100, SeekOrigin. Current);

//to write data flow
Byte [] data=https://bbs.csdn.net/topics/Encoding.UTF8.GetBytes (" hello word!" );
FileStream. Write (data, 0, the data Length);

//the data read from the stream, the count for the number of actual read
Int count=0;
Byte [] buff=new byte [1024].
If ((count=fileStream. Read (buff, 0, buff. Length)) & gt; 0)
{
Console. WriteLine (buff);
}
}
}

CodePudding user response:

That how can I express the read article n record gives the variable name?

CodePudding user response:

The
reference point 5 floor rabbit sauce reply:
 public class Test 
{
The public Test ()
{
Var fileStream=File. OpenWrite (" path ");

//set to the location of the current flow
FileStream. Seek (100, SeekOrigin. Current);

//to write data flow
Byte [] data=https://bbs.csdn.net/topics/Encoding.UTF8.GetBytes (" hello word!" );
FileStream. Write (data, 0, the data Length);

//the data read from the stream, the count for the number of actual read
Int count=0;
Byte [] buff=new byte [1024].
If ((count=fileStream. Read (buff, 0, buff. Length)) & gt; 0)
{
Console. WriteLine (buff);
}
}
}
understand, thank you??
  •  Tags:  
  • C#
  • Related