是否需要倒带ReadAllLines文件?

编程入门 行业动态 更新时间:2024-10-24 00:22:08
本文介绍了是否需要倒带ReadAllLines文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当调用列表框时,将执行以下例程.它会检查文本文件是否存在,如果存在,则从文件中读取每一行并将其添加到列表框中.

The following routine executes when a listbox is called. It checks if a text file exists, and if it does, then it reads each line from the file and adds them tothe listbox.

我遇到的问题是,如果我第二次打开列表框,则没有从文件中读取任何行.

The problem I'm having is if I open the listbox a second time,no lines are being read from the file.

这是因为文件位置在文件末尾吗?如果是,该如何倒带?

Is this because the file position is end-of-file? If so, how can I rewind it?

公共类Dialog_ListLoads 私有子对话框Dialog_ListLoads_Load(发送为System.Object,发送为System.EventArgs)处理MyBase.Load 暗淡的lines()作为字符串 昏暗的fname作为字符串

Public Class Dialog_ListLoads Private Sub Dialog_ListLoads_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim lines() As String Dim fname As String

ListBox1.Items.Clear() fname = ShaftAnalysis_Home& " \ 57_Load_List.txt"

ListBox1.Items.Clear() fname = ShaftAnalysis_Home & "\57_Load_List.txt"

如果System.IO.File.Exists(fname)= True,那么 行数= File.ReadAllLines(fname)

If System.IO.File.Exists(fname) = True Then lines = File.ReadAllLines(fname)

对于i As Integer = 0到lines.Count-1 ListBox1.Items.Add(lines(i)) 下一个 如果结束 结束子 结束班

For i As Integer = 0 To lines.Count - 1 ListBox1.Items.Add(lines(i)) Next End If End Sub End Class

迈克

推荐答案

迈克,你好

我认为与Visual Basic Windows窗体的静态行为有关.

I assume that it is more to do with the static behaviour of a Visual Basic Windows Forms.

那么更重要的是,您如何称呼该表格,然后可能有很多原因,您可以向我们展示一下吗?

More important is then how you call that form and then there can be many reasons, can you show that to us.

更多推荐

是否需要倒带ReadAllLines文件?

本文发布于:2023-07-11 09:13:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093542.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   ReadAllLines

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!