| | |
runtime error#58
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2005
Posts: 32
Reputation:
Solved Threads: 0
Runtime error 58 occurs when you try to rename a file with a name that already exists (in the same folder), or you try to save a new file with the same name as one that already exists (in the same folder).
With MSDOS, sorry Windows you cannot insert information into a file that already exists. The way around this is to first re-name the old file (so it is still there if you need it, a temporary file so to speak) with an obscure name (I use a few relevant "ABC" characters) plus a randomly generated number) for new name of the "old" file. Then I use a string to store the new name of the file (so I can still refer to it). Then you save the new information to the old file name (now you have re-named it, it won't clash). At this point if it goes wrong you can then re-name the "backup" file and you will be where you were before. If there is no problem and the new file is saved then you just delete the temporary file. If you don't then the folder will become full of the temporary files.
This sounds confusing. I think Comatose will understand what I mean. I hope you do as well.
With MSDOS, sorry Windows you cannot insert information into a file that already exists. The way around this is to first re-name the old file (so it is still there if you need it, a temporary file so to speak) with an obscure name (I use a few relevant "ABC" characters) plus a randomly generated number) for new name of the "old" file. Then I use a string to store the new name of the file (so I can still refer to it). Then you save the new information to the old file name (now you have re-named it, it won't clash). At this point if it goes wrong you can then re-name the "backup" file and you will be where you were before. If there is no problem and the new file is saved then you just delete the temporary file. If you don't then the folder will become full of the temporary files.
This sounds confusing. I think Comatose will understand what I mean. I hope you do as well.
If you are just trying to create a new file and want to delete the old file. use kill before your open statement. But like mrConfused stated, i would rename the file first. You might try nameing each file with the date and time, something like this usually does not get overwritten because the file name is always different, unless someone has reset the system clock or your writing more than one file per second.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
kill app.path & "\file.txt"
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Open App.Path & "\" & Year(Date) & Month(Date) & Day(Date) & Hour(Time) & Minute(Time) & Second(Time) & ".txt" For Output As #1
.: We may acquire liberty, but it is never recovered if it is lost :.
irc://irc.rizon.net/#itf
irc://irc.rizon.net/#itf
•
•
•
•
Originally Posted by lynfolan14
Runtime Error 58
.: We may acquire liberty, but it is never recovered if it is lost :.
irc://irc.rizon.net/#itf
irc://irc.rizon.net/#itf
![]() |
Similar Threads
- Runtime Error -21470024770 (8007007e) (Windows NT / 2000 / XP)
- Runtime Error 226 (Windows 95 / 98 / Me)
- "The Sims" visual C++ runtime error, what shall i do? (Windows Software)
- Visual Runtime Error, Sound Problem, Disabled Norton and more! (Windows NT / 2000 / XP)
- Runtime Error 424 object required (was: Please Help!) (Visual Basic 4 / 5 / 6)
- Runtime error using Incredimail on XP (Windows NT / 2000 / XP)
- Runtime error ??!! (Windows 95 / 98 / Me)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Day by being Monday, Tue etc...
- Next Thread: Newbie Help
Views: 14900 | Replies: 15
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






