Posts: 1,000
Threads: 253
Joined: Feb 2008
Gintaras,
Maybe this is a bug or I just don't know how it works.
Trying to use:
Ftp f.Connect("ftp.site" "user" "password")
str ss="Hello World"
int i=f.Cmd("STOR WLPO/TestZone/test.txt" ss 1 1)
out i
On the first run it does update the file but also gets this error:
'Exception 0xC0000005. Access violation. Cannot read memory at 0x0. In WININET.dll at 0x3D9345A1 (0x3D930000+0x45A1).' at 'r=InternetWriteFile(h data+nn data.len-nn &n)'
Also using and ftp client program trying to delete the file while QM is running, get "550 test.txt: The process cannot access the file because it is being used by another process."
Then doesn't update the file and returns 0 on other runs.
Have to restart QM.
Thanks,
Jimmy Vig
Posts: 1,000
Threads: 253
Joined: Feb 2008
Geeze...didn't read the disclaimer on the help file.
Is there any other way to pass data to a file on an ftp without having to first save data to a file and then upload that file?
I'd really like to avoid the extra step if I can.
Thanks,
Jimmy Vig
Posts: 12,141
Threads: 143
Joined: Dec 2002
Maybe it is this?
http://support.microsoft.com/kb/934376
Quote:Is there any other way to pass data to a file on an ftp without having to first save data to a file and then upload that file?
In wininet documentation I see 3 functions that can be used to put file to ftp.
1. FtpPutFile. It is used by
Ftp.FilePut. The local file must exist; cannot send just data.
2. FtpCommand/InternetWriteFile. It is used by
Ftp.Cmd.
3. FtpOpenFile/InternetWriteFile.
Posts: 12,141
Threads: 143
Joined: Dec 2002
Member function
Ftp.FilePutFromStr
function# str&data $ftpfile [failifexists] [ascii]
;Same as Ftp.FilePut, but the source data is in variable, not in file.
if(failifexists and Dir(ftpfile)) lasterror="ftpfile already exists"; ret
ascii=iif(ascii FTP_TRANSFER_TYPE_ASCII FTP_TRANSFER_TYPE_BINARY)
__HInternet h=FtpOpenFileW(m_hi @ftpfile GENERIC_WRITE ascii 0); if(!h) ret Error
if(!data.len) ret 1
int r n nn bs(4096)
rep
,n=data.len-nn; if(n>bs) n=bs
,r=InternetWriteFile(h data+nn n &n)
,if(!r) Error; break
,nn+n; if(nn>=data.len) break
ret r
err+ end "'%s' at '%s'" 0 _error.description _error.line
Posts: 1,000
Threads: 253
Joined: Feb 2008
This works great!
Is there any way to add data to a file at the beginning of the file? Like str.setfile [from] ?
Posts: 1,000
Threads: 253
Joined: Feb 2008
This machine does have Internet Explorer 7 too! Wow. Your on top of these things all the time!
Posts: 12,141
Threads: 143
Joined: Dec 2002
FtpOpenFile always replaces file. Probably need to download/modify/upload.
Posts: 1,000
Threads: 253
Joined: Feb 2008
Gintaras,
Any chances for
ftp.FileGetToStr member function?
Thanks,
jimmy Vig
Posts: 12,141
Threads: 143
Joined: Dec 2002
Member function
Ftp.FileGetToStr
function# $ftpfile str&data [ascii]
;Same as Ftp.FileGet, but stores file data in variable, not in file.
ascii=iif(ascii FTP_TRANSFER_TYPE_ASCII FTP_TRANSFER_TYPE_BINARY)
__HInternet h=FtpOpenFileW(m_hi @ftpfile GENERIC_READ ascii 0); if(!h) ret Error
int r n bs(4096)
data.fix(0)
rep
,data.all(data.len+bs 1)
,r=InternetReadFile(h data+data.len bs &n)
,if(!r) Error; break
,if(n=0) break
,data.fix(data.len+n)
ret r
err+ end "'%s' at '%s'" 0 _error.description _error.line
Posts: 1,000
Threads: 253
Joined: Feb 2008
Gintaras,
Your the best. This is perfect.
Thanks,
jimmy Vig