如何从文本文件中读取数据

如何从文本文件中读取数据

问题描述:

我正在开发一个复制/移动文件的应用程序



我想为它添加脚本功能。对于exaple,文本文件包含以下内容:



movefile =C:\ Pic1.jpg,C:\ Windows \Pic1.jpg



应用程序将读取以下文件并将pic1.jpg复制到C:\windows文件夹。但我是一个新手,我在许多论坛上搜索,但我找不到答案。请帮忙。



我的尝试:



my.computer .filesystem.movefile(C:\ Pic1.jpg,C:\ Windows \ pic1.hpg)

i'm developing a applicatin to copy/move files

i want to add script functionality to it. for exaple, a text files contains the following:

movefile = "C:\Pic1.jpg, C:\Windows\Pic1.jpg"

the application will read the follwoing file and copy the pic1.jpg to "C:\windows" folder. but i'm a newbie and i searched on many forums but i can't find the answer. please help.

What I have tried:

my.computer.filesystem.movefile("C:\Pic1.jpg, C:\Windows\pic1.hpg")

Quote:

想要为其添加脚本功能。

want to add script functionality to it.

您可以使用实际的脚本编程语言。例如,您可以使用VBScript。例如,请参阅 VB.NET Windows窗体中的VBScript - VB.NET | Dream.In.Code [ ^ ]

You could use an actual script programming language. For instance you could use VBScript. See, for instance VBScript In VB.NET Windows Form - VB.NET | Dream.In.Code[^]


使用 StreamReader类(System.IO) [ ^ ]这将允许您读取每一行。然后,您可以使用 String.Split方法(系统) [ ^ ]获取该行的单独部分。
Use the StreamReader Class (System.IO)[^] which will allow you to read each line. You can then use the String.Split Method (System)[^] to get the separate parts of the line.