|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB Smart Devivce ProgrammingHi all,
I just started a project in VB2005 for Smart Devices. For this I need to read a text file. Does anyone have a code snippet of how this is done? I mapped a directory to emulate the storage card and copied the file in there. In the file manager of the device emulator I can see the file there. But I have no idea how to access the file (directory name, etc.) Hope anyone can help Regards, Martin
http://groups.google.com/group/microsoft.public.dotnet.framework.compactframework/browse_thread/thread/e1bdf126973f74c3/b387a559c709ed%23b387a559c709ed
Show quote Hide quote "Martin" <x@y.com> wrote in message
news:uonI%23zQKHHA.1816@TK2MSFTNGP06.phx.gbl... > Hi all, > > I just started a project in VB2005 for Smart Devices. For this I need to > read a text file. Does anyone have a code snippet of how this is done? I > mapped a directory to emulate the storage card and copied the file in > there. In the file manager of the device emulator I can see the file > there. But I have no idea how to access the file (directory name, etc.) > > Hope anyone can help > Regards, > Martin > Hi,
Here is a code snip. It uses the OpenFileDialog control. Note, I am using it to read data in "chunks" from a file and then to send those "chunks" out the serial port. However, you can do equivalent things (such as simply displaying the file), rather than sending it. OpenFileDialog1.ShowDialog() Dim Filename As String = OpenFileDialog1.FileName If Filename <> "" Then Dim fs As New System.IO.FileStream(Filename, IO.FileMode.Open, IO.FileAccess.Read) 'declaring a FileStream to open the file with access mode of reading logReader = New System.IO.BinaryReader(fs) 'creating a new StreamReader and passing the filestream object fs as argument logReader.BaseStream.Seek(0, IO.SeekOrigin.Begin) Dim FileLength = logReader.BaseStream.Length Dim BytesRemaining As Integer = FileLength With SerialPort Do Until BytesRemaining < SerialPort.WriteBufferSize Try Dim buffer(.WriteBufferSize - 1) As Byte buffer = logReader.ReadBytes(.WriteBufferSize) ..Write(buffer, 0, .WriteBufferSize) BytesRemaining -= .WriteBufferSize Catch ex As Exception Exit Do End Try Loop 'etc For this reason, I use a BinaryReader. You might choose to use a TextReader instead. If you examine the Filename result from the OpenFileDialog, you can see how paths are handled for Storage Cards. Dick -- Richard Grier, MVP Hard & Software Author of Visual Basic Programmer's Guide to Serial Communications, Fourth Edition, ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March 2006. See www.hardandsoftware.net for details and contact information. Thanks for your help, got it to work now.
Show quoteHide quote "Martin" <x@y.com> wrote in message news:uonI%23zQKHHA.1816@TK2MSFTNGP06.phx.gbl... > Hi all, > > I just started a project in VB2005 for Smart Devices. For this I need to > read a text file. Does anyone have a code snippet of how this is done? I > mapped a directory to emulate the storage card and copied the file in > there. In the file manager of the device emulator I can see the file > there. But I have no idea how to access the file (directory name, etc.) > > Hope anyone can help > Regards, > Martin >
Launching Web site for help
Cross: Access speed Small question? Why does this not work? What am I doing wrong? PrintDocument_PrintPage goes into endless loop until e.HasMorePages=False Print font not available after assigning PrinterName vbc : error BC30420: 'Sub Main' was not found in 'Product'. Is it necessary to close a local OleDbDataReader before exit function? Webbrowser Changing user interface |
|||||||||||||||||||||||