Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ftp File Modify
#1
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
#2
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
#3
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 http://Ftp.FilePut. The local file must exist; cannot send just data.
2. FtpCommand/InternetWriteFile. It is used by http://Ftp.Cmd.
3. FtpOpenFile/InternetWriteFile.
#4
Member function Ftp.FilePutFromStr
Code:
Copy      Help
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
#5
This works great!

Is there any way to add data to a file at the beginning of the file? Like str.setfile [from] ?
#6
This machine does have Internet Explorer 7 too! Wow. Your on top of these things all the time!
#7
FtpOpenFile always replaces file. Probably need to download/modify/upload.
#8
Gintaras,

Any chances for http://ftp.FileGetToStr member function?

Thanks,
jimmy Vig
#9
Member function Ftp.FileGetToStr
Code:
Copy      Help
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
#10
Gintaras,
Your the best. This is perfect.
Thanks,
jimmy Vig


Forum Jump:


Users browsing this thread: 1 Guest(s)