如何在vb.net中保存Listbox [英] how to save Listbox in vb.net

查看:453
本文介绍了如何在vb.net中保存Listbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只有列表框中的文件名,并希望将所有项目保存到另一个文件夹



Only filenames in Listbox, and want to save all item to another folder

Dim files() As String
files = Directory.GetFiles("C:\", "*.txt")

Dim file As String
For Each file In files
lstFiles.Items.Add(Path.GetFileName(file))
Next





输出:



output :

00001.txt
00003.txt
00005.txt ....



想要将ListBox的内容保存到另一个文件夹。


want to save the content of a ListBox to another folder.

推荐答案

尝试:

Try:
File.WriteAllLines("D:\Temp\MyListBoxContent.txt", lstFiles)





但请注意,如果这是真的是VB.NET,那么文件列表和保存位置都将在服务器上,而不是客户端:VB代码在服务器上执行,无法访问客户端磁盘。



But do be aware that if this is really VB.NET, then the list of files and the save location will both be on the Server, not the Client: VB code is executed at the server, and cannot access Client disks.


这篇关于如何在vb.net中保存Listbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆