Leggere e scrivere in un file

giovedì 10 maggio 2007 - 16.51

m485 Profilo | Newbie

Ciao a tutti..

Devo fare una cosa semplice ma sto impazzendo a farla..
Sto facendo un'applicatico in vb.net che giri su un palmare in cui è installato
windows CE
.
L'applicativo deve leggere un file, fare una minima interrogazione e salvare tutto in fondo ad un'altro file ... Tutto qui...

Un'applicazione base base riesco a farla girare sul palmare, ma la lettura e la scrittura sul file non so proprio che comandi utilizzare.

Sul mio pc ho fatto un'applicativo windows che funziona, ma alcuni comandi se creo un progetto per windows CE nn le riconosce.

Questo è piu o meno il codice che devo "tradurre":

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub cmdEsci_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdEsci.Click
Close()
End Sub

Private Sub cmdSalva_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSalva.Click
Dim x As Object
Dim ind, nomef As Object
Dim riga As String
Dim cod(10) As String
Dim y As Short
nomef = Text1.Text
ind = "F:\Visual Basic\progetto\" + nomef + ".txt"

On Error GoTo nuovo
FileOpen(2, ind, OpenMode.Input)
x = 1
Do While EOF(2) = False
Input(2, riga)
If riga <> "" Then
cod(x) = riga
x = x + 1
End If
Loop
FileClose(2)

On Error GoTo errore
FileOpen(1, ind, OpenMode.Output)
For y = 1 To x
If cod(y) <> "" Then PrintLine(1, cod(y))
Next
PrintLine(1, Text1.Text & " ; " & Text2.Text & " ; " & Text5.Text & " ; " & txtData.Text & " ; " & txtOra.Text & " ;")
FileClose(1)
Exit Sub
nuovo:
'Dim risposta1 As String
'risposta1 = MsgBox("Nuovo file", vbExclamation, "nuovo file")
On Error GoTo errore
FileOpen(1, ind, OpenMode.Output)
PrintLine(1, Text1.Text & " ; " & Text2.Text & " ; " & Text5.Text & " ; " & txtData.Text & " ; " & txtOra.Text & " ;")
FileClose(1)
Exit Sub
errore:
'Dim risposta As String
'risposta = MsgBox("Impossibile aprire il file", vbExclamation, "errore apertura file")
End Sub

Private Sub avanzamento_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
txtData.Text = CStr(Today)
txtOra.Text = CStr(TimeOfDay)
End Sub

Private Sub Text2_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Text2.TextChanged
Dim x As Short
Dim ind As Object
Dim nomef As String
Dim cod(5) As String
ind = "F:\Visual Basic\progetto\operatori.txt"
Text3.Text = ""

On Error GoTo errore
FileOpen(2, ind, OpenMode.Input)
For x = 1 To 4
Input(2, cod(x))
If Left(cod(x), 1) = Text2.Text Then
Text3.Text = LTrim(Replace(cod(x), Text2.Text, ""))
FileClose(2)
Exit Sub
End If
Next
FileClose(2)
Exit Sub
errore:
'Dim risposta As String
'risposta = MsgBox("Impossibile aprire il file", vbExclamation, "errore apertura file")
End Sub
End Class

------------------------------------------------------------------------------------------------


sarei veramente grato se qualcuno mi desse una mano...
grazie grazie grazie

Brainkiller Profilo | Guru

>Sul mio pc ho fatto un'applicativo windows che funziona, ma alcuni
>comandi se creo un progetto per windows CE nn le riconosce.
>sarei veramente grato se qualcuno mi desse una mano...
>grazie grazie grazie

I comandi che non ti riconosce evidentemente non sono supportati dal Compact Framework. Il compact framework è un subset del framework .net quindi ridotto, molti metodi non ci sono, così come molte classi, bisogna consultare MSDN e vedere in fondo ad ogni metodo o classe se è supportata da Compact Framework o meno.

Questo è il problema che incontrano molti che pensano che per migrare una applicazione di Windows a WinCE basti copiare l'eseguibile Purtroppo non è proprio così.
Ciao


David De Giacomi | Microsoft MVP
http://blogs.dotnethell.it/david/
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5