全心思齐网

如何在资源管理器中创建,复制,移动,删除或重命名文件或文件夹?

VS中的文件操作:

复制:system.io.file.copy(从哪里复制,到哪里)

粘贴:上方的可以实现复制粘贴

重命名:system.io.file.move(文件目录\旧的文件名,文件目录\新的文件名)

新建:.......

删除:system.io.file.delete(文件名)

剪切:system.io.file.move(从哪里剪切,到哪里)

VS中的文件夹操作:

新建:system.io.directory.createdirectory("位置")

其他的都与文件操作类似,把file替换为directory即可

来个演示:(VB .NET)

点击Button1复制,点击Button2粘贴

Button1_Click:

dim strcopyfile1 as string

txtfileinfo1.text=strcopyfile1

Button2_Click:

dim strcopyfile2 as string

if system.io.file.copy(strcopyfile1,strcopyfile2) =false then

messagebox "文件复制失败!"

end if

匿名回答于2019-12-04 00:21:38


相关知识问答