Reading files using file system control

Reading files using file system control

Post by Warwick Payte » Sun, 05 Jan 2003 13:17:15



Hi I am trying to open a text file using embedded visual
basic to read two columns of numbers
1200, 10
3456, 22
4555, 50

etc
I am trying to use the file system control ie
file.open pathname, mode, access, lock, reclength
-----------------------------
Private Sub Command1_Click()
Dim pth As String
pth = "c:\wmp\filetest\test2.txt"
File1.Open pth, 1, 1, 3, 32000
End Sub
-----------------------------
I keep getting an error (filname, dir name, or vol labe
syntax is incorrect)

Does any body have a code fragement for this?
What should the record length be ?
When in emulator mode does the pth start at the normal
windows dir or at the emulator dir?

 
 
 

Reading files using file system control

Post by Keld Laurse » Mon, 06 Jan 2003 23:00:21




Quote:> pth = "c:\wmp\filetest\test2.txt"
> I keep getting an error (filname, dir name, or vol labe
> syntax is incorrect)

On CE devices, you don't have drive letters, so the line should read:
pth = "\wmp\filetest\test2.txt"

At least, that's how it is with the pictures I load and the text file I read
in a current project.

Keld Laursen

 
 
 

Reading files using file system control

Post by Keld Laurse » Tue, 07 Jan 2003 16:24:58





> > pth = "c:\wmp\filetest\test2.txt"
> > I keep getting an error (filname, dir name, or vol labe
> > syntax is incorrect)

> On CE devices, you don't have drive letters, so the line should read:
> pth = "\wmp\filetest\test2.txt"

Here is how I read/write a text file (a single-line file, but still...:

Public Sub InitSettings()
Dim sf As File

    Set sf = MainForm.SetupFile
    On Error Resume Next
        Err = 0
        sf.Open "\My Documents\Lommebedrift.Set", fsModeInput, fsAccessRead,
fsLockRead
        If Err Then
            sf.Open "\My Documents\Lommebedrift.Set", fsModeOutput,
fsAccessWrite, fsLockWrite
            sf.LinePrint "-1"
            sf.Close
            CurrentRecNo = -1
        Else
            Err = 0
            CurrentRecNo = CLng(sf.LineInputString)
            If Err Then
                CurrentRecNo = 0
                IncRecNo ' For at skrive setupfilen!
            Else
            End If
            sf.Close
        End If
    On Error GoTo 0
    Set sf = Nothing
End Sub

Public Sub IncRecNo()
Dim sf As File
    Set sf = MainForm.SetupFile
    On Error Resume Next
        MainForm.ChkFile.Kill "\My Documents\Lommebedrift.Set"
        CurrentRecNo = CurrentRecNo - 1
        Err = 0
        sf.Open "\My Documents\Lommebedrift.Set", fsModeOutput,
fsAccessWrite, fsLockWrite
        sf.LinePrint CStr(CurrentRecNo)
        sf.Close
    On Error GoTo 0
End Sub

Keld Laursen