Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi folks. Newbie user here! Hope I'm in the right place - apologies if not.

 

I'm having problems with the file handling syntax:

 

I'm using:

 

File_Name = "\iPAQ File Store\locs.txt"

Dim sr As System.IO.StreamWriter = File.CreateText(File_Name)

 

sr.WriteLine(LB_LOCATION.Items(t))

 

to write data to a file. I can read the created file with no problem using Notepad.

 

However, using:

 

Dim sr As System.IO.StreamReader = New System.IO.StreamReader("\iPAQ File Store\locs.txt")

 

sline = sr.ReadLine

LB_LOCATION.Items.Add(sline)

 

to read the file in VB .net results in peculiar control characters being read in.

 

Any ideas what I am doing wrong? Is there another syntax I should use?

 

Many thanks

 

Cavan

  • Leaders
Posted

You probably need to open the file with File.OpenText("\iPAQ File Store\locs.txt") to read the data in. :)

SR = File.OpenText("\iPAQ File Store\locs.txt")

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted

Thanks Iceplug, appreciate the response. I think I tried that earlier today, with the same result. I've tried three or four different ways of opening the file in VB.Net but just get gobbledegook back in. As I mentioned, the file seems fine - I can open it in notepad or word and the content is fine. Unfortunately, I really need to be able to read it back in to my application.

 

Incidentally, I've been programming with VB.net for precisely one day! I've got my application virtually finished on the Ipaq. I just can't do this usually simple thing - writing and reading back from a file.

 

Thanks again

 

Cavan

Posted

Hi Mutant - thanks for the replay.

 

Just as a simple test I output the word 'test' to the file. As I said I can see it perfectly in things such as Notepad and Word. I haven't had the the app in front of me since last week, but from memory, the result of the read back in the app is 6 characters in contrast to the 4 letters of 'test'.

 

The first 2 characters are squares. Then something like !):;

 

Cheers

 

Cavan

  • *Experts*
Posted

Try to change the encoding:

Dim reader As New System.IO.StreamReader("file", System.Text.Encoding.UTF7)
'there is more encodings there

Posted

Way to go Mutant! It works! Thanks VERY much.

 

I tried all the encoding options and got it to work with 'Default'. Interesting. Since I didn't actually specify any encoding I would have thought it would have used default by default :)

 

Thanks again. Much appreciated.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...