open file error

This is a discussion on open file error within the Windows Programming forums, part of the Platform Specific Boards category; No, "\text.txt" is a valid file name, just as ".\text.txt" or "..\text.txt" are - they are relative filename not absolute ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    No, "\text.txt" is a valid file name, just as ".\text.txt" or "..\text.txt" are - they are relative filename not absolute filenames, but nevertheless, valid.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    no, ".\text" is a name with . + tab + "ext.txt", which is not valid.
    Use any character in the current code page for a name, including Unicode characters, except characters in the range of zero (0) through 31, or any character that the file system does not allow. A name can contain characters in the extended character set (128–255). However, it cannot contain the following reserved characters:

    < > : " / \ | ? *
    Last edited by robwhit; 12-19-2007 at 05:28 PM.

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    It's a path. Though I don't know if CreateFile will interpret an absolute path or directory of if it will just accept a filename in the current directory.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Quote Originally Posted by Elysia View Post
    It's a path. Though I don't know if CreateFile will interpret an absolute path or directory of if it will just accept a filename in the current directory.
    Ummmm...

    No it is not.

    A '\' is not a character. A '\' requires a second character in all cases.

    '.\\' or '..\\' is a path

    As Robwhit said, the compiler reads '\t' as a TAB, making '.\text.txt' == '. ext.txt'

    I suggest you try this in your compiler and report your results.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #20
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    And why don't you just use CFile and CArchive if you are using MFC in the first place??

  6. #21
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    Quote Originally Posted by novacain View Post
    Ummmm...

    No it is not.

    A '\' is not a character. A '\' requires a second character in all cases.

    '.\\' or '..\\' is a path

    As Robwhit said, the compiler reads '\t' as a TAB, making '.\text.txt' == '. ext.txt'

    I suggest you try this in your compiler and report your results.
    We're talking about real paths here, now how you type them in your compiler
    Obviously, in a C++ string, you'd have to type ".\\text.txt", which would translate to ".\text.txt".

    And why don't you just use CFile and CArchive if you are using MFC in the first place??
    Now there's something I just can't agree less with.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #22
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Quote Originally Posted by Elysia View Post
    We're talking about real paths here, now how you type them in your compiler
    Obviously, in a C++ string, you'd have to type ".\\text.txt", which would translate to ".\text.txt".
    I am/was not sure the OP understood that.....

    EDIT: My previous post was directed at the OP (but reads as if directed at you. Which was not my intention, sorry.)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  8. #23
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    Alright, no harm done
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. file reading
    By gunghomiller in forum C++ Programming
    Replies: 9
    Last Post: 08-07-2007, 10:55 PM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

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