My program can't read an internet file!

This is a discussion on My program can't read an internet file! within the Windows Programming forums, part of the Platform Specific Boards category; This script can read Settings.txt fine. ( Code: char Buffer[10]; DWORD dwBytes; HANDLE hExtra; hExtra=CreateFile("File.txt", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, ...

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Question My program can't read an internet file!

    This script can read Settings.txt fine. (

    Code:
     
    char Buffer[10];
    DWORD dwBytes;
    HANDLE hExtra;
    hExtra=CreateFile("File.txt", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    ReadFile(hExtra, BufferT, 100, &dwBytes, NULL);
    But when I try to make it read a file that is over the internet, if doesn't find the file, as if though it doesn't exist. Why is is doing this, and how can I get it to read a file that is on the net?

    Thanks, August.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    CreateFile does not open URLs. To download a file from the web, you can use the wininet API. Wininet sample here.

  3. #3
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Okay, I looked at your examples it has one example for DOS and Windows. But the Windows example does not have a int_main function. So I don't know how to use it.

    Plus these examples download the file, I want it to just read the file, that's all.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Those are both windows examples, allthough anonytmouse's example contains code to display output to a console. An example dosen't have to be a complete program just to show you how to do something.
    You have to download files located on the internet (at least to memory). If you wanted you could create a function to check weather a file path is local or on the internet and then call the apropriate function that way you could call the same function to read local and remote files.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Read data from file - C program ?
    By Pawan Sangal in forum C Programming
    Replies: 2
    Last Post: 08-22-2008, 04:28 AM
  3. Read a file into a loop program
    By TimeClock in forum C Programming
    Replies: 5
    Last Post: 07-17-2003, 06:29 PM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21