473,479 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB Smart Devivce Programming

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
Dec 26 '06 #1
3 1040
http://groups.google.com/group/micro...b387a559c709ed

"Martin" <x@y.comwrote in message
news:uo****************@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

Dec 26 '06 #2
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.
Dec 26 '06 #3
Thanks for your help, got it to work now.

"Martin" <x@y.comwrote in message
news:uo****************@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

Dec 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2777
by: Evan | last post by:
Chandra Shekhar Kumar <chandra.kumar@oracle.com> wrote in message news:<3EF64860.3FCC6E7F@oracle.com>... > donot use dude pointers ...use smart pointer instead There's a problem with this...
27
3362
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined...
1
1515
by: Smith | last post by:
Are attributed ATL projects be supported under Whidbey for Smart Devices? The New ATL Project dialog box doesn't have the 'Attributed' check box for smart devices projects in Beta1, but Win32...
59
5051
by: MotoK | last post by:
Hi Experts, I've just joined this group and want to know something: Is there something similar to smart pointers in C or something to prevent memory leakages in C programs. Regards MotoK
92
4994
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers,...
54
11900
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining...
4
1868
by: Jack | last post by:
Hi, In multi-thread programming, if I using smart pointers to store pointers to the same dynamically allocated objects, can memory leak be avoided? For example, two threads share the same...
5
2870
by: Noozer | last post by:
I'm looking for a "smart folder" program to run on my Windows XP machine. I'm not having any luck finding it and think the logic behind the program is pretty simple, but I'm not sure how I'd...
50
4421
by: Juha Nieminen | last post by:
I asked a long time ago in this group how to make a smart pointer which works with incomplete types. I got this answer (only relevant parts included): ...
0
6899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7067
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6719
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5312
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2980
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2970
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
555
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.