Add a comment. Active Oldest Votes. Improve this answer. Yes, but it is much easier using the FileSystemObject, and once you have started using that, you will see that there are also many other useful file system methods on that object The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. Connect and share knowledge within a single location that is structured and easy to search. It works fine unless a user has the file open.
I tried creating a copy of the file, then uploading that copy, but to my surprise, the FileCopy procedure gets a "permission denied" error whenever you try to copy a file that is open by the user. This suprised me, because you can copy a file in Windows Explorer while it is open, and I was assuming that the FileCopy method used the same API call as explorer.
Based on this article , the answer that worked for me is described below. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How can I copy an open file using VB6? There also this error message will be displayed and the application will be collapsed. The what is a solution. Any idea? Once again Please mind, I am very new to programming, and have only little knowledge about computers.
If you put your database on D: drive you will get "permission denied" too. It doesn't matter if it's on C: drive or on D: drive. You will get "permission denied" if your database is on whatever drive. So this is not the root cause of your problem.
You can prevent "permission denied" errors by closing every open ADO connection to your database. So to prevent read permission errors while copying your database file you have to first close every ADO connection that might lock portions of this database file so that FileCopy can succeed.
Closed all database files before copying,But still the same result. Thanks Try copying the. If you have server-side recordsets or ADODC controls littered across application forms this might even be mission impossible. You would only need to do this in rare cases. It was only ever intended for very simple programs. Use its bigger brother instead: DataEnvironment. Then any other idea for copying the database file ,in case any thing happens to the computer of the user.
Mind, it should be easy for a person who has little knowledge about computer. NET VB. Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation.
This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace. Remember Me? Advertiser Disclosure.
Advanced Search. Results 1 to 29 of Thread: how to copy a file in vb6. I have a problem in fso. Please help me in copying files and how to rename them. Follow Post Reply. Thanks Hey - You can also try it. This code will copy a file, and of the same time, will rename a file. Expand Select Wrap Line Numbers. Killer42 8, Expert 8TB. What sort of problem? Hey - You can also try it. Don't do that, just execute the CopyFile. I use and an error of syntax error. If you code it exactly as shown, I think it will work.
Can you explain it to me. That's the whole of it. The Name x As y command renames a file and if necessary, moves it to a different folder. Look it up in your VB doco.
0コメント