file saving??

This is a discussion on file saving?? within the Windows Programming forums, part of the Platform Specific Boards category; Hi: I would like to save my own file (not *.txt, it contains picture and text), just like other softwares ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    173

    Question file saving??

    Hi:
    I would like to save my own file (not *.txt, it contains picture and text), just like other softwares can save their own files. Is there any hint or way for me to do this?

    I would appreciate that.
    Don't laugh at me,I am just a SuperNewbie.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    173
    Thanks, mate. I've not yet tried, but I think there should be a Open or Save As dialog box pops up, then when we click "Save", it saves a file. and When we click "Open", it opens the relevant file type.

    This file can contains any kinds of data, just like in the games(NOT only text), they have their own file types. Besides, I don't know if "fopen" can really save and open any kinds of data.

    I am quite new on "save file" stuff, I would really appreciate that if someone is gonna help me and give me some hints, thanks alot.
    Don't laugh at me,I am just a SuperNewbie.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You mean GetOpenFileName and GetSaveFileName

    But they will only give you the file name selected - you have to write the code to actually work with the file. For this you can use fopen as it can write binary as well as text.

    Or you can use iostreams or the API file functions - the choice is yours

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    173
    Thanks again, GetOpenFileName and GetSaveFileName only show the dialog.

    But could you please tell me that whether all the files are either in Binary or text? just files of all kinds, like... for instance, one software: user template (user can save his settings and load it next time when running the program).

    Also, own made file can be named as any just like "*.abc" or something? and can be only open by the software which creates it.

    Sorry for bothering you again. , thanks.
    Don't laugh at me,I am just a SuperNewbie.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by SuperNewbie
    But could you please tell me that whether all the files are either in Binary or text? just files of all kinds, like... for instance, one software: user template (user can save his settings and load it next time when running the program).
    Internally, all files are treated the same - they are just full of numbers, but programmers make a distinction between binary and text based files for convinience. If you want the data to be readable, use text, if you dont want readbility and want speed, use binary

    Originally posted by SuperNewbie
    Also, own made file can be named as any just like "*.abc" or something? and can be only open by the software which creates it.
    You can edit the registry to create a new class for your file type, then windows will open your app and pass the name of the file through the command line

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    173
    Thanks for your help, I've got a idea.
    Don't laugh at me,I am just a SuperNewbie.

  8. #8
    Registered User
    Join Date
    Nov 2003
    Posts
    53
    This is good

    Only prob is that I myself cant seem to find out what it is they want me to do

    It says :
    You create and display an Open dialog box by initializing an OPENFILENAME structure and passing the structure to the GetOpenFileName function.
    I dont understand what is meant...how do i make that structure?(and pass it on.. i know what settings i want) a bit of help would be nice

    (btw sorry for asking questions in your thread SuperNewbie but it is kind of the same topic)
    Its all a matter of willpower

  9. #9
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544

  10. #10
    Registered User
    Join Date
    Sep 2001
    Posts
    173
    To Oluf:

    I think OPENFILENAME is the structure which contains the property the file that you are gonna handle, for instance:

    "lpstrFilter" is the file type that gonna handle, " lpstrFile" is the initialized file name when Saving a file.

    So before Open or Save file, we must initialze it with our desired properties. (At least we know what kind of file type we r handling )

    Because GetOpenFileName and GetSaveFileName both are doing something about the file, that's why we have to pass the OPENFILENAME structure to the GetOpenFileName function.

    I hope I don't misundertand your meaning. . thanks by the way for the link.
    Don't laugh at me,I am just a SuperNewbie.

  11. #11
    Registered User
    Join Date
    Nov 2003
    Posts
    53
    anonytmouse I am in the middel of that tutorial...but as I said i dont know how to make the struct for GetOpenFileName

    thanks for your reply superNewbie (you cant be all newbie hehe) but I dont follow you 100%....still got no idea how to pass the struct...other then that I understand what you are saying
    Its all a matter of willpower

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

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