VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A code that enables saving in long file names format in Visual Basic 3.0. See more info in the code

by SW (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Sun 1st October 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A code that enables saving in long file names format in Visual Basic 3.0. See more info in the code or email the author.

Rate A code that enables saving in long file names format in Visual Basic 3.0. See more info in the code



'tries to create a file, for example OPEN "C:\YADAYADAYADA.TXT" FOR OUTPUT AS
'1, the file name will be shortened to eight character format: "C:\YADAYADA.TXT"
'This code snippet exploits the fact that the command prompt under XP still
'allows long file names, and hence renames the saved file under the command
'prompt after saving it. Just replace yadayada.ini with the first 8 
'characters of what your long filename would be.
'
'By SW 2006 -- [email protected] -- long live Trotskyism
'and Workers Power!

'Don't use any path for the NewFileName
filepath="C:\"
OldFileName = filepath & "yadayada.ini"
NewFileName = "yadayadayada.ini"
Open OldFileName For Output As #1
Print #1, "Here goes the"
Print #1, "info for the OldFileName file"
Print #1, "that you want to save"
Close 1

'Creates a Batch file to rename the file to its long file name
Open "C:\buk.bat" For Output As #2
Print #2, "@ren %1 %2"
Close 2

x = Shell("C:\buk.bat " & OldFileName & " " & NewFileName)

MsgBox "Saved " & filepath & newfilename & " successfully."

'If you want to, you can of course delete the Batch file that renames the
'file, but VB is quicker than the Batch, so if you just put the delete
'command right after the execution of it, it will be deleted before it
'can be executed! So put it at the close of the form or whatever:
'Kill "C:\buk.bat"

Download this snippet    Add to My Saved Code

A code that enables saving in long file names format in Visual Basic 3.0. See more info in the code Comments

No comments have been posted about A code that enables saving in long file names format in Visual Basic 3.0. See more info in the code. Why not be the first to post a comment about A code that enables saving in long file names format in Visual Basic 3.0. See more info in the code.

Post your comment

Subject:
Message:
0/1000 characters