如何使用vb.net将文件移动到文件夹 [英] How to move file to folder using vb.net

查看:396
本文介绍了如何使用vb.net将文件移动到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用vb.net将所选文件移动到文件夹。


我目前有这个代码


如果File.Exists(C:\Documents and Settings \ 055949x \transfer \ text.txt)和Not File.Exists(C:\Documents and Settings \ 055949x \transfer \ text.txt")然后


File.Move(" C:\Documents and Settings \ 055949x \transfer \ text.txt"," C:\文件和设置\ 055949x \Desktop \AES file \transfer \ text.txt")

Label1.Text =(" File moved!")

Else

Label1.Text =(文件不存在)

结束如果


如何制作它确定我将能够移动不同的文件,而无需编写文件的完整目录?我需要移动已在gridview上显示的文件。


ps我正在使用vb.net 2005

解决方案

< blockquote>您可以使用相关目录位置。和..


thanx回复。你能告诉我怎么做吗?我实际上对vb.net很新吗?



thanx的回复。你能告诉我怎么做吗,因为我真的对vb.net很新吗?



假设您的代码可执行文件正在目录C:\Documents and Settings \ 055949x \目录中运行......

展开 | 选择 | Wrap | 行号


Hi, i would like to move a selected files to a folder using vb.net.

I currently have this code

If File.Exists("C:\Documents and Settings\055949x\transfer\text.txt") And Not File.Exists("C:\Documents and Settings\055949x\transfer\text.txt") Then

File.Move("C:\Documents and Settings\055949x\transfer\text.txt", "C:\Documents and Settings\055949x\Desktop\AES file\transfer\text.txt")
Label1.Text = ("File moved!")
Else
Label1.Text = ("File does not exist")
End If

How to i make it sure that i will be able to move different files without having to write the full directory of the file? I need to move the files that had been display on gridview.

p.s I''m using vb.net 2005

解决方案

You can use relative directory locations like . and ..


thanx for the reply. Can u show me how to do it caz i''m actually quite new to vb.net?


thanx for the reply. Can u show me how to do it caz i''m actually quite new to vb.net?

Assuming that your code executable is running in the directory C:\Documents and Settings\055949x\ directory...

Expand|Select|Wrap|Line Numbers


这篇关于如何使用vb.net将文件移动到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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