Does anyone know if it is possible to read random access files in C #?
I am trying to replicate the following function (from an old VB6 application) in C # -
Open File For Random Shared As
EDIT -
Now I tried using the VisualBasic DLL as suggested below and getting the following error in the FileGetObject line -
"The best overloaded method match for Microsoft.VisualBasic.FileSystem.FileGetObject (int, ref object, long) has some invalid argument
The code I use is
public class Record { public int DMtype; public long ecn; public Record(int DMtype, long ecn) { this.DMtype = DMtype; this.ecn = ecn; } public Record() { } } string fileName = @"C:\RandomAccess.dat"; string returnString = string.Empty; int row = 1; int maxRow = 1000; Record aFileRecord = new Record(); FileSystem.FileOpen(1, fileName, OpenMode.Random, OpenAccess.Read, OpenShare.LockRead); while (row < maxRow) {
I tried to set the "Record" to both the structure and the class and get the same error.
EDIT 22/08/13 . I did not get to the end, as a result, exported random access data to split text files in VB6, and then consumed the files in SSIS.
source share