Indigo Rose Software

Professional Software Development Tools

 
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Jan 2004
    Posts
    33

    Peekaboo! Simple questions from a newbie

    I am trying to copy files from my cd to the hard drive. Here is what I have so far:

    result = Dialog.Message("Notice", "Would you like to install your customized company database?", MB_YESNO, MB_ICONINFORMATION, MB_DEFBUTTON1);
    if (IDYES) then
    File.Copy("Directmail & Attachments\\Attachments.dat", "C:\\Quantum\\Data\\", true, false, false, true, nil);
    File.Copy("Directmail & Attachments\\directmail.mdb", "C:\\Quantum\\Data\\", true, true, false, true, nil);
    File.Copy("Hvac\\Database\\HVAC01.DAT", "C:\\Quantum\\Data\\", true, false, false, true, nil);
    end
    result = Dialog.Message("Notice", "Database Files Installed Successfully.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

    I need for it the code to detect if all 3 files already exist and and not copy the ones that do exist and copy the ones that don't. Then give a dialog message that tells the user which files existed and that the system can not copy them. If none of the files exist then I would just like a dialog message that says "Database Files Installed Sucessfully".

    Hope someone can help me with this.

    Thank you guys.

    AMy

  2. #2
    Join Date
    Dec 2003
    Posts
    891

    question

    Is there a reason that you can't just set the filecopy for not overwrite. You wouldn't need a confirmation on the files that DO already exist.
    makes a difference in the example I would give you.

  3. #3
    Join Date
    Jan 2004
    Posts
    33
    Using the filecopy to not overwrite would be ok. Thanks for your help. Its greatly appreciated.

  4. #4
    Join Date
    Nov 2003
    Location
    Salzburg / Austria
    Posts
    312
    Not the shortest one, but it should work.

    Code:
    t_file={}
    t_file[1]="Directmail & Attachments\\Attachments.dat";
    t_file[2]="Directmail & Attachments\\directmail.mdb";
    t_file[3]="Hvac\\Database\\HVAC01.DAT";
    OK=true;
    Info="";
    if (IDYES) then
      for x,act in t_file do
        actfile=String.SplitPath(act).Filename..String.SplitPath(act).Extension;
        if not File.DoesExist("C:\\Quantum\\Data\\"..actfile) then
          --file doesn't exist -> copy
          File.Copy("Directmail & Attachments\\"..actfile, "C:\\Quantum\\Data\\", true, false, false, true, nil);
        else
          Info=Info.."file ".."C:\\Quantum\\Data\\"..actfile.." exists and won't be copied.\r\n"
          OK=false;
        end;
      end;
      if OK then
        result = Dialog.Message("Notice", "Database Files Installed Successfully.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
      else
        result = Dialog.Message("Notice", Info, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
      end;
    end;

    Stefan_M
    "With a rubber duck, one's never alone."

    Douglas Adams, The Hitchhiker's Guide to the Galaxy

  5. #5
    Join Date
    Jan 2004
    Posts
    33
    Stephan,

    That works great! Except for one thing, it's not coping the HVAC01.DAT FILE, I can't figure it out.

    Thanks,

    Amy

  6. #6
    Join Date
    Dec 2003
    Posts
    891

    short one

    just a query to install, create the install folders (only if they don't already exist), file copy with no overwrite, and process complete confirmation. If the files are huge, then we can put in a progess dialog, also.
    Attached Files

  7. #7
    Join Date
    Nov 2003
    Location
    Salzburg / Austria
    Posts
    312
    Sorry didn't testet it

    Code:
    t_file={}
    t_file[1]="Directmail & Attachments\\Attachments.dat";
    t_file[2]="Directmail & Attachments\\directmail.mdb";
    t_file[3]="Hvac\\Database\\HVAC01.DAT";
    OK=true;
    Info="";
    if (IDYES) then
      for x,act in t_file do
        actfile=String.SplitPath(act).Filename..String.SplitPath(act).Extension;
        if not File.DoesExist("C:\\Quantum\\Data\\"..actfile) then
          --file doesn't exist -> copy
          File.Copy(t_file[x],  "C:\\Quantum\\Data\\", true, false, false, true, nil);
        else
          Info=Info.."file ".."C:\\Quantum\\Data\\"..actfile.." exists and won't be copied.\r\n"
          OK=false;
        end;
      end;
      if OK then
        result = Dialog.Message("Notice", "Database Files Installed Successfully.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
      else
        result = Dialog.Message("Notice", Info, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
      end;
    end;
    change
    File.Copy("Directmail & Attachments\\"..actfile, "C:\\Quantum\\Data\\", true, false, false, true, nil);
    to
    File.Copy(t_file[x], "C:\\Quantum\\Data\\", true, false, false, true, nil);


    Stefan_M
    "With a rubber duck, one's never alone."

    Douglas Adams, The Hitchhiker's Guide to the Galaxy

  8. #8
    Join Date
    Jan 2004
    Posts
    33

    Wink Thanks for your all your help!

    Thanks for all your help Stephan. This is not the first time you have helped me with some coding. I really appreciate it.

    Amy

  9. #9
    Join Date
    Jan 2004
    Posts
    33

    Files are being copied as Read only.

    The code works great, but now when the files are copied they are copied as read only. My access database will not work with the attributes set as read only. Can you add to the code to change or set the file atttributes to uncheck the readonly option? Thanks a bunch!

    Amy

  10. #10
    Join Date
    Dec 2003
    Posts
    891

    with attrib

    this will set the read only to false after the files are copied.
    Attached Files

  11. #11
    Join Date
    Jan 2004
    Posts
    33
    I am using Stephan's code above and I need the file attributes worked into his code. I tried pasting yours, but it blew it up. Can you help me by adding it into his code. Thanks.


    Amy

  12. #12
    Join Date
    May 2001
    Location
    51.531249 | -0.610962
    Posts
    1,244
    Paste this in. You can paste it after Stefan's code if you wish.

    Code:
    attrib = File.GetAttributes("C:\\Quantum\\Data\\Attachments.dat");
    attrib.ReadOnly = false;
    File.SetAttributes("C:\\Quantum\\Data\\Attachments.dat", attrib);
    If you need this on the other 2 files, simply create it again for the other 2 and change the filename
    -
    = Derek
    ["All glory comes from daring to begin" - fortune cookie]

  13. #13
    Join Date
    Nov 2003
    Location
    Salzburg / Austria
    Posts
    312
    simply insert the function 'File.SetAttributes' after the File.Copy operation.

    Code:
          File.Copy(t_file[x], "C:\\Quantum\\Data\\", true, false, false, true, nil);
          File.SetAttributes("C:\\Quantum\\Data\\"..actfile, ReadOnly=false);

    Stefan_M
    "With a rubber duck, one's never alone."

    Douglas Adams, The Hitchhiker's Guide to the Galaxy

  14. #14
    Join Date
    May 2001
    Location
    51.531249 | -0.610962
    Posts
    1,244
    Of course, i'm forgetting the attrib table is 'built-in'
    Dont forget curly braces with that:

    File.SetAttributes("C:\\Quantum\\Data\\"..actfile, {ReadOnly=false});
    -
    = Derek
    ["All glory comes from daring to begin" - fortune cookie]

  15. #15
    Join Date
    Nov 2003
    Location
    Salzburg / Austria
    Posts
    312
    Shame on me.

    To much copy and paste and no tests.


    I'm going to stand in the corner for a while.

    Stefan_M
    "With a rubber duck, one's never alone."

    Douglas Adams, The Hitchhiker's Guide to the Galaxy

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Newbie questions...
    By Martin_SBT in forum Visual Patch 1.0
    Replies: 2
    Last Post: 09-21-2004, 04:01 PM
  2. Few simple questions...
    By daveinmb in forum AutoPlay Media Studio 5.0
    Replies: 7
    Last Post: 03-22-2004, 01:49 AM
  3. Newbie thank's & questions
    By Col_in_UK in forum AutoPlay Media Studio 4.0
    Replies: 4
    Last Post: 05-30-2003, 11:52 AM
  4. Newbie question, this has got to be a simple just don't know why
    By shogo in forum AutoPlay Media Studio 4.0
    Replies: 3
    Last Post: 05-24-2003, 01:18 PM
  5. A few, possible simple questions
    By polonia in forum AutoPlay Menu Studio 3.0
    Replies: 3
    Last Post: 09-05-2001, 11:28 PM

Posting Permissions

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