Results 1 to 5 of 5

Thread: File already exist...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Québec, Canada
    Posts
    284

    File already exist...

    I have a sub that saves all the information I have in a file. Now I would like my sub to do just like almost all the "save" function do which is to check if the name already exist and see if the person want to replace it.... How do I do this??
    Here's a part of the code I already have:
    VB Code:
    1. Dim intFileNo As Integer
    2.    
    3.     With dlg
    4.         .Filter = "Protoypes (.c .cpp)|*.c;*.cpp|"
    5.         .FilterIndex = 1
    6.         .DefaultExt = "c"
    7.         .FileName = nomFich
    8.         .ShowSave
    9.     End With
    10.  
    11. intFileNo = FreeFile
    12.  
    13. Open dlg.FileName For Binary As intFileNo
    14.         Put intFileNo, , str
    15.     Close intFileNo

    Thanx in advance

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. Dim intFileNo As Integer
    2.    
    3.     With dlg
    4.         .Flags = cdlOFNOverwritePrompt ' <--------------
    5.         .Filter = "Protoypes (.c .cpp)|*.c;*.cpp|"
    6.         .FilterIndex = 1
    7.         .DefaultExt = "c"
    8.         .FileName = nomFich
    9.         .ShowSave
    10.     End With
    11.  
    12. intFileNo = FreeFile
    13.  
    14. Open dlg.FileName For Binary As intFileNo
    15.         Put intFileNo, , str
    16.     Close intFileNo

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Québec, Canada
    Posts
    284
    Thank you!! but now, how do I know if the person said yes or no whether or not he wanted to replace it??

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    If you click 'No', it should keep the dialog open until you pick another file, or hit cancel.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Location
    Québec, Canada
    Posts
    284
    Hahahaha!! That's right!!

    I made a mistake in my cut and paste...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width