|
-
Sep 3rd, 2008, 04:43 AM
#1
Thread Starter
New Member
[RESOLVED] [2008] Can't find text file on C: drive
I have a small app running on a windows Mobile 6 device and wrote the following to read a text file
Code:
Dim FILE_NAME As String = "C:\test.txt"
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
TextBox1.Text = objReader.ReadToEnd
objReader.Close()
Else
MsgBox("File Does Not Exist")
When I debug this using the "Windows Mobile 6 Professional Emulator" option I get "File Does Not Exist".
I am reasonably sure the file name is spelt correctly - should I be specifying it as something different to "c:\" for the emulator, please?
I have not tried it on the device itself yet.
Any help would be appreciated.
-
Sep 3rd, 2008, 05:26 AM
#2
Frenzied Member
Re: [2008] Can't find text file on C: drive
Hi,
pocket pc does not have a concept of c:\ drives, or any drives for that matter.
If you do
Dim FILE_NAME As String = "\test.txt"
That is in the root folder
"test.txt" is in the same folder as your application, and "\My Documents\test.txt" is in the My Documents folder
Pete
-
Sep 3rd, 2008, 08:34 AM
#3
Thread Starter
New Member
Re: [2008] Can't find text file on C: drive
many thanks for that Pete - I suspected that it must be something like that, so was pleased to get the correct format ...
sorry for the delay in replying but I have been having a lot of trouble getting this working .. and still it does not work - despite the fact that I have dotted files all around the place ... and even tried creating a file to see where it was created .. the following worked fine in concept - but still no file could be found. This must be some characteristic of the Emulator I feel sure..
Code:
Dim FILE_NAMEw As String = "\test3.txt"
Dim objWriter As New System.IO.StreamWriter(FILE_NAMEw, False)
Dim testtext As String = "this is the test"
objWriter.WriteLine(testtext)
MsgBox("File created - " & FILE_NAMEw)
objWriter.Close()
Dim FILE_NAME As String = "\test3.txt"
If System.IO.File.Exists(FILE_NAME) = True Then
MsgBox("File ok - " & FILE_NAME)
Dim objReader As New System.IO.StreamReader(FILE_NAME)
TextBox1.Text = objReader.ReadToEnd
objReader.Close()
Else
MsgBox("File Does Not Exist - " & FILE_NAME)
I am now having a think - and read - to see if the emulator requires some different approach - I may even deploy it to the device to see if that makes a difference
-
Sep 3rd, 2008, 12:36 PM
#4
Frenzied Member
Re: [2008] Can't find text file on C: drive
Hi,
the emulator should be no different.
Have you looked on the emulator to see if the file does indeed exist?
-
Sep 3rd, 2008, 12:55 PM
#5
Thread Starter
New Member
Re: [2008] Can't find text file on C: drive
I did a search of the PC - C:\ drive for the file - test3.txt - and it didn't exist ? Even though it had created it - read it - and displayed the contents (see my code) according to the messagebox displays ?
The emulator normally undoes everything - so that did not surprise me too much. But I am unsure where else to look ?
-
Sep 3rd, 2008, 01:15 PM
#6
Thread Starter
New Member
Re: [2008] Can't find text file on C: drive
I have just deployed the app to the device (HP IPAQ) and it works fine - I used \my documents\test.txt as you suggested.
It is strange that I couldn't get it working under emulation - I may just be putting the file in the wrong place - but at least I can proceed now.
Many thanks Phil. I will wait a short while to see if there are any further comments re the emulator - but will set it as resolved tomorrow morning.
-
Sep 3rd, 2008, 02:32 PM
#7
Frenzied Member
Re: [2008] Can't find text file on C: drive
Hi,
you need to look using explorer in the emulator.
The emulator is the same as the device - doesn't know anything about a c:\ drive or any drive on your PC, unless you map to it as a shared folder.
BTW - It's Pete
-
Sep 3rd, 2008, 04:57 PM
#8
Thread Starter
New Member
-
Sep 4th, 2008, 01:17 AM
#9
Frenzied Member
Re: [2008] Can't find text file on C: drive
Hi,
in Visual Studio, do Tools>Device Emulator Manager.
When your emulator is running, you should see in the list it is connected. Simply right-click on the connection, and click on 'cradle' - this will run activesync and connect it. Then you can explore it just like a device, and drag and drop files
HTH
-
Sep 4th, 2008, 06:56 AM
#10
Thread Starter
New Member
Re: [2008] Can't find text file on C: drive
:-)
Thanks very much for that ....
I had to run ActiveSync from the PC first - to setup the connection - but I imagine that will be just the first time - it will probably run automatically from here on.
All is now working well - and I cannot thank you enough.
regards Lol
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|