CreateFolder()出错? [英] Error in CreateFolder()?

查看:260
本文介绍了CreateFolder()出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。


当我使用CreateFolder()创建一个末尾有空格的文件夹时,

它会成功创建文件夹,但仍然错误输出路径

未找到错误。


例如:

<%

Dim strCurrentPath


strCurrentPath =" c:\ test folder \


如果不是oFO.FolderExists(strCurrentPath)那么

oFO.CreateFolder(strCurrentPath)''错误在这一行。

结束如果

%>


创建文件夹后,无法删除或重命名

立即。我认为仍然必须附加一些程序。尝试删除时出现

错误:无法删除文件:无法从源文件或磁盘读取



我现在需要能够离开这个空间。


关于为什么会发生这种情况的任何想法?


谢谢!

解决方案

就像后面一样,我可以通过添加on error来解决这个问题。周围

createFolder(),但我宁愿到达错误的底部。


这是我要做的事情的一个例子:


<%

Dim strCurrentPath

Dim strErrNum,strErrMessage


strCurrentPath =" c:\ test文件夹\


如果不是oFO.FolderExists(strCurrentPath)那么

On Error Resume Next

oFO.CreateFolder(strCurrentPath)

如果不是oFO.FolderExists(strCurrentPath)那么

strErrNum = Err.number

strErrMessage = Err。描述

结束如果

On Error GoTo 0

如果Len(strErrMessage)> 0然后

Err.Raise strErrNum,CreateFolder(),strErrMessage

结束如果

结束如果

%>


经过一些调查后,看来如果你不用尾随

" \"在路径上,文件夹成功创建没有错误,

和尾随空格被剥离。


不幸的是,如果你是FileExists()寻找c:\ test

\ folder \ test.txt"它不会剥离而且它不匹配。


在一个更大的笔记(稍微)上这是在asp.net中完成所有
$ b在存在()和createfolder()上删除了$ b尾随空格,有或没有

最后的\。


< blockquote>我不明白你为什么要在末尾创建一个带空格的文件夹?


" anjelone" <一个****** @ gmail.com>在消息中写道

news:11 ********************** @ j33g2000cwa.googlegr oups.com ...

经过一番调查后,看来如果你不在尾随
\在路径上,文件夹成功创建,没有错误,
和尾随空格被剥离。不幸的是,如果你正在寻找c:\,请使用FileExists() test
\ pdder\test.txt"它不会剥离而且它不匹配。

在一个更加简单的说明(略),这是在asp.net中处理,所有
尾随空格被删除存在( )和createfolder()有或没有
最后的\。



Hi.

When I use CreateFolder() to create a folder with a space at the end,
it creates the folder successfully, but still errors out with a "Path
not Found" error.

For example:
<%
Dim strCurrentPath

strCurrentPath = "c:\test folder \

If Not oFO.FolderExists(strCurrentPath) Then
oFO.CreateFolder(strCurrentPath) ''Errors on this line.
End If
%>

After the folder is created, it cannot be deleted or renamed
immediately. I think there still must be some process attached. The
error when trying to delete it is: "Cannot delete file: Cannot read
from the source file or disk."

I need to be able to leave the space in for now.

Any ideas on why this occurs?

Thanks!

解决方案

Just as a follow on, I can get around this by adding "on error" around
the createFolder(), but I''d rather get to the bottom of the error.

Here is an example of something I would do:

<%
Dim strCurrentPath
Dim strErrNum, strErrMessage

strCurrentPath = "c:\test folder \

If Not oFO.FolderExists(strCurrentPath) Then
On Error Resume Next
oFO.CreateFolder(strCurrentPath)
If Not oFO.FolderExists(strCurrentPath) Then
strErrNum = Err.number
strErrMessage = Err.Description
End If
On Error GoTo 0
If Len(strErrMessage) > 0 Then
Err.Raise strErrNum, "CreateFolder(), strErrMessage
End If
End If
%>


After some investigation, it appears that if you leave off the trailing
"\" on the path, the folder gets created successfully with no error,
and the trailing space gets stripped off.

Unfortunately, with FileExists() if you are looking for "c:\test
\folder\test.txt" it won''t strip and it won''t match.

On a brigher note (slightly) this is taken care of in asp.net with all
trailing spaces removed on exists() and createfolder() with or without
the final "\".


I cant see why you would want to create a folder with a space at the end?

"anjelone" <an******@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...

After some investigation, it appears that if you leave off the trailing
"\" on the path, the folder gets created successfully with no error,
and the trailing space gets stripped off.

Unfortunately, with FileExists() if you are looking for "c:\test
\folder\test.txt" it won''t strip and it won''t match.

On a brigher note (slightly) this is taken care of in asp.net with all
trailing spaces removed on exists() and createfolder() with or without
the final "\".



这篇关于CreateFolder()出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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