File I/O

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I'm having issues with populating my SqlServer Ce
Database with a text file. My issue is that I can't seem
to "find" my sample data file that I have on my hard
drive.

I have added the text files to the project in the
Solutions explorer but still can't find it. I've tried
DriectoryInfo.Exists. File.Exists. But when I run my
program using the Emulator it comes back FALSE. Did not
find.

Any suggestions anyone? Thank you.

Mike
 
Mike,

How are you deploying the file to the emulator? If you've included it in
your project, make sure the Build Action is set to None. Then when you
deploy your app, the file will be deployed to the same folder as your EXE.
Be sure to use the full path name of the file when you reference it inside
your app.
 
Ginny - Yes I am deploying it to the Emulator. Where is the Build Action
at? I had tried looking at the properties for the actual text file for
the build properties but did not see anything.

IS this a good way to go about this. The code I,m working on will need
to be able to snag a different text file for populating my Sql Server CE
DB every week or so.

And lastly. Doing it this way with the Build Action set to None. I'l
still be using the StreamReader and File.Open with the full path to say
"C:\ReadIN\test.txt" correct?

Thanks for the fast reply.

Mike
 
Hi Mike,

In the Solution Explorer, right-click on the file. Then select Properties
from the context menu. The Build Action should be at the top, and select
Content (sorry, not None - my mistake).

This is a pretty good solution for testing, but you'll need something easier
for weekly use. I'd suggest writing a little desktop Rapi app that prompts
(or knows?) which file to copy down. You can copy it to whatever folder you
want, but if the folder doesn't exist, you must create it first.You'll need
to give the file each week the same name so your PPC app can find it. You
can find a .Net wrapper for Rapi on www.opennetcf.org in the Communcation
section.

If the folder on your device is named ReadIn, then the full path name of the
file is "\ReadIn\text.txt" without the C:
 
Ginny - I have the Build Action set to Context for it. I can see it
saying that it copies the text files. But evertyime I try to find the
directory or files I get DirectoryNotFound errors and FileDoesNotExist
errors.

If I have the files in the project. Do I need to do some file maping
calls?

path = "\TestData\test.txt"

Dim sr As System.IO.StreamReader
Dim Contents As String
Dim found As Boolean
found = System.IO.File.Exists(path)
If found Then
sr = New StreamReader(path, System.Text.Encoding.ASCII)
Contents = sr.ReadToEnd()
sr.Close()
Return Contents
End If


That's the simplelil TextReader function. Have tried a couple variations
of the StreamReader. And have tried searching for my text files that
were copied to the Emulator(according to the Build window).

Am at wits end and appreciate all your help. Thanks.

Mike
 
Yes I can. It says Mobile Device. When I click on it a wndow for
ActiveSync comes up.
 
Ginny - I was finally able to access the files today. Thanks for all
your help. After I had ActiveSnc installed at the work site I was able
to check and create directories. THen later I was able to find the text
files on the Emulator which then told me where I had to read them from.
Not the Hard Drive file location on my pc but the text file loacation on
the emulator.

Thanks again.

MadtownMike
 
Back
Top