我的代码命名文件:为什么不能重命名文件?在vb.Net
Dim strFilename ="D:\2014\RF見本_P330_115%11.ai"
Dim newfile="D:\2014\RF見本_P330_115_11.ai"
My.Computer.FileSystem.RenameFile(strFilename , newfile)
但它出现的错误:Unable to find the specified file.
为什么呢?如何重命名此文件? 谢谢大家。
我的代码命名文件:为什么不能重命名文件?在vb.Net
Dim strFilename ="D:\2014\RF見本_P330_115%11.ai"
Dim newfile="D:\2014\RF見本_P330_115_11.ai"
My.Computer.FileSystem.RenameFile(strFilename , newfile)
但它出现的错误:Unable to find the specified file.
为什么呢?如何重命名此文件? 谢谢大家。
该问题可能与除语言/指令之外的其他内容有关。我在这里创建了相同的结构,并且副本正常执行。
检查文件是否有一些特殊设置(如READONLY,PROTECTED等),并且您是否有权限访问它及其文件夹。
I'm使用:VS2013,.NET框架4.0,Windows 8.1中
My.Computer.FileSystem.RenameFile
不能用于将文件移动到新位置。要执行此操作,新名称参数不能包含路径信息,并且不能以\
结束。如果file
参数存在,那么当你拥有它,现在你应该得到一个ArgumentException
用的消息:
Argument 'newName' must be a name, and not a relative or absolute path
要解决这个问题,你根本不包括在你的newFile
参数的路径:
Dim strFilename ="D:\2014\RF見本_P330_115%11.ai"
Dim newfile="RF見本_P330_115_11.ai"
My.Computer.FileSystem.RenameFile(strFilename , newfile)
该文件是否存在于该路径? – ScottMcGready
是的,它是存在的。 –
这是你收到的确切错误信息吗? –