VBScript错误#71

扫码查看
本文介绍了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

推荐答案


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

05-27 20:27
查看更多