Ravi
Ravi

Reputation: 1

Error 70 VB6 exe application

I am getting error 70 intermittently while running my VB6 Exe application.

I try to open a text file as given under from a class function. The text is on the filer (network file server)

I tried to delay on catching the error 70. Later on close the file and re-open. But that didn't work either.

Code:

If FreeFile > 1 Then
   Close #1
End If

Open FileName1 For Append As #1  (I am getting Error 70)
Print #1, StringOut
Print #1, ""
Print #1, ""
Print #1, ""

Close #1

Open FileName2 For Append As #2
Print #2, StringOut
Close #2

Close

Upvotes: 0

Views: 711

Answers (2)

JeffK
JeffK

Reputation: 3039

Error 70 is "Permission denied."

Can you open that file with notepad, change it, and save it? If not, solve that problem first, then look at your code.

Upvotes: 0

George Mastros
George Mastros

Reputation: 24498

You should be using the value returned by the free file function, so a slight change is in order.

Dim File1Number As Integer
Dim File2Number As Integer

File1Number = FreeFile

Open FileName1 For Append As #File1Number   (I am getting Error 70)
Print #File1Number , StringOut
Print #File1Number , ""
Print #File1Number , ""
Print #File1Number , ""

Close #File1Number 

File2Number = FreeFile
Open FileName2 For Append As #File2Number
Print #File2Number, StringOut
Close #File2Number

Close #File2Number

Upvotes: 2

Related Questions