Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open text File

Status
Not open for further replies.

T111

Programmer
Jun 28, 2003
91
0
0
IE
I have to ftp files to a location, but the user wants me to be sure I have exclusive rights to the folder. A dummy file exists called Test.txt. If I can open that file for input then I have exclusive rights to the folder. I tried to open it as follows

Dim FilePath5, strbuffer As String

FilePath5 = "fimport = 6
Open FilePath5 For Input As #fimport

but got the following error - Error number = 52 bad file name or number.

I was given a username and password and they are stored in the batch file when I am ftp the file but first I need to know if I have exclusive rights to the folder.

Has anybody got a solution?
 
Fist test it for your localmachine,

Filepath = "c:\empfolder\temp.txt"

Idf this works then the problem lays with your filepath i think the problems lays with the ip in the fie name but try it out and let us know.
 
Two points that may help you.

First point is your variable Filepath5 is actually being declared as a variant rather than a string as it lokks like you intended, to correct this you need to declare the variables as
Code:
Dim FilePath5 As String, strbuffer As String

Second point,It is normally a good idea to get a filenumber using FreeFile as this ensures that the file number you assign is not in use elsewhere in the project.
Code:
fimport = FreeFile

(I assume that somewhere you have Dim fimport As Integer or similar)

HTH,

Dave
 
You can't use 16 bit file functions like Open and freefile to read or write via HTTP. You need to use sockets to read or write over HTTP or TCP/IP.

To write you need to post your data to an ASP page for example, and let that write to the server.

To read you need to get the response from the server when you hit that page.

I recommend you look at the MSWinsock component that allows a simple interface into sockets programming.

Hope this helps,

VBrit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top