Link to home
Start Free TrialLog in
Avatar of Tim Turner
Tim TurnerFlag for United States of America

asked on

VB6 File "Save As" routine

I know how to do a File -> Save... and I have code to do File -> Save As and prompt user for file name and location....

But in most applications, if you do a "save as" the result is that the version you were in is closed and you are not "working in the new save as file"...  My program is not set up that way.... My program just saves a copy of the eixsting file off to the filename and location specifed from the dialog... it then does not "switch to that file" which has caused some confusion...

Can anyone provide any pointers in this area?  I have searched EE and Google and not found anything on:
- the correct expected procedure
- coding hints to implement that

Some type of work flow in general plus code tips is what I need... My "brute force" thought is just:
- user working in File 1
- does Save As to File2
- date from File 1 is copied and saved into File 2 on the hard drive
- File 1 is then "closed"
- File 2 is then "opened"

Thoughts?  Help?  Suggestions?
-Tim
Avatar of Crash2100
Crash2100
Flag of United States of America image

What type of file are you working with?  Just a simple text file?
ASKER CERTIFIED SOLUTION
Avatar of Dana Seaman
Dana Seaman
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tim Turner

ASKER

Hmmm I'll have to double check but I'm not 100% sure I close the file after opening and reading the data....  I think it stays open until you close or exit the program....  

Using what you suggest... the file would be closed after opening and reading... then if saved... I would actually open the file and save it again... using the filename/path I have stored... so same deal with save as...

When I open and read a file am I supposed to set seomthing that prevents others from opening and using same file?  I see word creating these ~filename entries in same folder which I think is used to protect from multiple users editing???
Crash
The file is actually a binary file that I save and load UDTs from.
Once you read the File there would be no need to keep it open.

Since the file is always closed others could open and modify it but then when you save it overwrites with new changes you have made or better yet use Save As to create a new FileName.

As to Word ~filename entries I think that is in case you use "Save" which would normally overwrite the original but in this case they make a copy of original as "~filename" so that you could recover the original if needed.
Quick adjunct to this question.... danaseaman.. related to the "~filename" directory entries... I thought those were just placeholders to PREVENT multiple users editing a file.... so on open you check for ~filename and if it exists then don't allow user to open it.  And on close you delete ~filename. ????  In the case of Word I have not seen that the ~ files contain anything so I thought it was real basic mutli-user edit prevention....

Do you know anything about this?  Most of our users are not sharing files but a few of them are trying to share data files over a server....
Quick adjunct to this question.... danaseaman.. related to the "~filename" directory entries... I thought those were just placeholders to PREVENT multiple users editing a file.... so on open you check for ~filename and if it exists then don't allow user to open it.  And on close you delete ~filename. ????  In the case of Word I have not seen that the ~ files contain anything so I thought it was real basic mutli-user edit prevention....

Do you know anything about this?  Most of our users are not sharing files but a few of them are trying to share data files over a server....
Quick adjunct to this question.... danaseaman.. related to the "~filename" directory entries... I thought those were just placeholders to PREVENT multiple users editing a file.... so on open you check for ~filename and if it exists then don't allow user to open it.  And on close you delete ~filename. ????  In the case of Word I have not seen that the ~ files contain anything so I thought it was real basic mutli-user edit prevention....

Do you know anything about this?  Most of our users are not sharing files but a few of them are trying to share data files over a server....
for some reason every time I view this page it reposts the same comment... dont know why it's doing that... thanks danaseaman I'll look at that later when I get the time.... -Tim
Avatar of Netminder
Netminder

torrid333,

Can you please post some details about your system (OS and browser, any firewall or proxy information) here: http:/Q_22966357.html.

DanRollins has kindly posted the above question so we can figure out what's going on with your posts.

Netminder
Site Admin