Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / December 2005

Tip: Looking for answers? Try searching our database.

How can I open a Random file with a structure in compact framework

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luis Ramos - 29 Dec 2005 23:47 GMT
Happy new year for everybody...

My problem is this:
I can open a random file with vs2005 this way(normal project), but not in a
smart device project.

example of the way i do in a normal project:
    Structure Record  
            public ID As Integer
            public Cod as short
            <vbfixedString(50)> public Name As String
            <vbfixedString(50)> public Adress as String
            <vbfixedString(50)> public City as String
            public Sit as single
    End Structure

private sub button_click() etc.....
    Dim MyRecord As Record  
    FileOpen(1, "TESTFILE", OpenMode.Random)
         Do While Not EOF(1)  
              FileGet(1, MyRecord)
              ListBox1.items.add MyRecord.name
         Loop
    FileClose(1)  
end sub()

My question is:
    How can i open this file in the Compact Framework, smart device project?
    Can somebody give-me a exemple of how to do it real close to the one i
wrote here?

    Thanks for your attention and colaboration

     Luis
<ctacke/> - 30 Dec 2005 00:05 GMT
The CF doesn't support the operations you're trying to use.  The solution is
to quit using legacy file commands and use Stream-based file operations.  A
stream works in about the same way anyway.  Open, seek based on your
structure size and then read.

-Chris

> Happy new year for everybody...
>
[quoted text clipped - 32 lines]
>
>      Luis
Luis Ramos - 31 Dec 2005 01:47 GMT
ctacke, MANY THANKS FOR YOUR HEPL, BUT I DIDN´T Found it yet.
Here is the thing i am making as you said, but it doen´t work, can you see
what am i making wrong? I can not assign the string to the variant of the
structure. see the code here:
this is the module with the structure:
-------------------------------------------------------------------------
Module Module1
   Public Structure clientes
       Public codint As Short
       <VBFixedString(15)> Public CODCLi As String
       <VBFixedString(50)> Public Nome As String
       <VBFixedString(50)> Public Morada As String
       <VBFixedString(50)> Public Locali As String
       <VBFixedString(50)> Public Estab As String
       <VBFixedString(15)> Public Contrib As String
       <VBFixedString(15)> Public TelefE As String
       <VBFixedString(15)> Public TelefR As String
       <VBFixedString(15)> Public TeleM As String
       <VBFixedString(15)> Public Fax As String
       <VBFixedString(30)> Public Mail As String
       Public PrazV As Short
       Public vend As Short
       <VBFixedString(10)> Public UVenda As String
       <VBFixedString(10)> Public PVenda As String
       Public ctip As Short
       Public CZon As Short
       Public cszon As Short
       Public DESC As Short
       Public PzPag As Short
       Public Situacao As Short
   End Structure

this is the way i am trying to acess the data in teh random file:
------------------------------------------------------------------------

Imports System
Imports System.IO
Imports System.Text
Imports Microsoft.VisualBasic

Public Class Form3

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
       Const fileName As String = "clibas.dbf"
       Dim Linha As String
       Dim dat As New clientes
       Dim dataarray(357) As Byte
       Dim fileStream As FileStream = New FileStream(fileName, FileMode.Open)

       Try
           ' Set the stream position to the beginning of the stream.
           fileStream.Seek(0, SeekOrigin.Begin)
           ' Read and verify the data.
           For i As Integer = 0 To 357
               TextBox1.Text = TextBox1.Text + fileStream.ReadByte()
           Next i

       Finally

' an error here where a canot put the data comming from the filestream to
the variant in the module

           DAT= TEXTBOX1.TEXT
           ListBox1.Items.Add(dat.codint)
           ListBox1.Items.Add(dat.CODCLi)
           ListBox1.Items.Add(dat.Nome)

           fileStream.Close()
       End Try
   End Sub
end class

can you help-me to this problem?
Thanks and have a very good year 2006
happy new year
Luis

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.