VBScript错误#71 [英] VBScript Error #71

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

问题描述

大家好,

我正在尝试在vbs中编写一个非常简单的查找和替换功能.

每次运行脚本时,都会出现访问被拒绝/磁盘未就绪的错误. (#71)
我做错了什么?

Hi Guys,

I''m trying to write a very simple find and replace function in vbs.

Each time I run the script I get an access denied/ disk not ready error. (#71)
Anything I''m doing wrong?

Dim objFSO, objFile, strText, strNewText
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Text.txt", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "Jim", "James")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Text.txt", ForWriting)
objFile.WriteLine strNewText
objFile.Close


-------------------------------------------------- ------
该文件存在,并且用户可以访问它.我可以在记事本中对其进行编辑.
错误优先出现在这里:


--------------------------------------------------------
The File Exists, and the user can access it. I can edit it just fine in notepad.
The Error First appears here:

Set objFile = objFSO.OpenTextFile("C:\Scripts\Text.txt", ForReading)


-------------------------------------------------- -----
我通过以正确的编码格式打开文件来解决此问题.


-------------------------------------------------------
I Fixed this by opening the file in the correct encoding format

推荐答案

您的第一步应该是:

确认text.txt文件存在.
确认您可以在Notebook =>中读写文件.如果没有,您可能会遇到用户权限问题.

要提供更多帮助,我们需要导致错误的行.

当您有更多信息时,请编辑您的问题,请不要添加额外的答案.
Your first steps should be:

Confirm the text.txt file exists.
Confirm you can read and write to the file in Notebook => If not you might have user permissions problems.

To give more help we''ll need to which line is causing the error.

When you have more info, edit your question, please don''t add an extra answer.


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

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