CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2009
    Posts
    13

    [RESOLVED] Read file like Notepad

    Hi all,

    I need to read the following file in vb .net: "C:\Windows\SoftwareDistribution\DataStore\DataStore.edb". It contains info about installed software updates. I've taken a look at the file by opening it with notepad. This isn't a plain-text file obviously, but I can find and see the text I want easily with Notepad, and I want to extract this text by using VB .NET.

    The problem is, i've tried to read the file by using an io.streamreader, but I can't get the same results as in notepad. I've tried to change encoding but that doesn't work. I mean in Notepad, I can read some text easily: "A s e c u r i t y i s s u e h a s b e e n i d e n t i f i e d" [...], but the only thing I get with the streamreader is some bunch of ugly characters, and the text I saw with Notepad isn't there.

    Do I have to read the file in binary or what? HOW NOTEPAD DOES IT? HOW DO I READ THIS FILE LIKE NOTEPAD DOES?

    I absolutely need to extract some updates info that aren't in either the registry or WMI/QFE.

    Any idea?

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Read file like Notepad

    If you just read the entire file into a string and display it in a text box I would expect that you should see the same text as you see in notepad, assuming you are using the same font. IF there are nulls in the file this may supress any text that comes after the null though. Not sure if Notepad continues after a null but I think it does, a text box may not but all the text shoudl be contained in the string the same as it is shown in notepad with possibly some additional characters that you do not see in notepad.

  3. #3
    Join Date
    Jan 2009
    Posts
    13

    Thumbs up Re: Read file like Notepad

    problem solved: there were actually nulls in the file. I just replaced them with the following code: .Replace(Convert.ToChar(0), " ")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured