Results 1 to 5 of 5

Thread: Text file to listview, with premature EOF...

  1. #1

    Thread Starter
    Lively Member THCfog's Avatar
    Join Date
    Oct 2002
    Location
    Michigan
    Posts
    86

    Text file to listview, with premature EOF...

    I have a decent sized list of lines which i load to a listview using a traditional list opening code (below). All works well, but encountering certian strings which are apparently EOF markers cut things off early leaving my list half empty.

    VB Code:
    1. Open "C:\FileCodeList.txt" For Input As #1
    2.     Do While Not EOF(1)
    3.     Line Input #1, str1
    4.     If Left(str1,7)="KeepC:\" Then ListView1.ListItems.Add , , str1
    5.     Loop
    6.     Close #1

    Ive read many articles on open as binary, but i cannot get any sort of list population going with that. Plus, i cannot store the entire file as a array due to its large size. From 1 to 150 MB.

    Im not sure if i should somehow process the file before loading, removing or replacing all Null characters or EOF marking characters ( im not sure what they are) , or if there is a binary loop i can use to load this list successfully.

    Amy help would be much appreciated. Thanks ahead of time.
    Last edited by THCfog; Jun 29th, 2005 at 08:25 PM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Text file to listview, with premature EOF...

    Could you attach a sample of your txt file for me to check your code?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Lively Member THCfog's Avatar
    Join Date
    Oct 2002
    Location
    Michigan
    Posts
    86

    Re: Text file to listview, with premature EOF...

    For a example of my error, add this to a text file in UNICODE format.
    "KeepC:\FileName.txt;~Ty"
    "KeepC:\FileName1.txt;‚Š~{"
    "KeepC:\FileName3.txt;910w>"
    "Success"


    You will see it never reaches Success.

    ~ I have found that this error only happens when the file is in Unicode format. When i manually change it to ANSI or UTF-8, it loads. However some characters are then changed. Is there a way Open for input as UTF-8 or ANSI? Or if i was to convert the entire txt file to one of those 2 formats, a way to get it back to Unicode to see the original string while adding to the listview.

    Thanks

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Text file to listview, with premature EOF...

    Are you writing the file? Writing it normally from VB is in unicode isn't it?

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5

    Thread Starter
    Lively Member THCfog's Avatar
    Join Date
    Oct 2002
    Location
    Michigan
    Posts
    86

    Re: Text file to listview, with premature EOF...

    Im not writing any files or i wasnt... I think i might take the TYPE route , dynamic creating of batch files for a conversion. TYPE UNICODE > ASCI... I dont mind using batch commands to assist me in loading this list, so ill label this as semi-resolved for now.

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