default name for the FileSaveBox - Forum

Forum Navigation
You need to log in to create posts and topics.

default name for the FileSaveBox

How do I set a default file name for the FileSaveBox? I can set the file type, but the name field is blank.

I want it to be a pre-chosen name....

Hi!

FileSaveBox "" "" "[PubDir]DefaultName.txt" "[file]"

Thank you Vadim.

 

Here is what I actually want to do:  A file is opened with the name Myfile.txt. It is edited in my program and then saved with the suggested name of NewMyfile.txt. Not so important to add "New" to the name, but it helps the user know what file was modified, and it can be automated to edit and save files without user intervention. I have seen it done with so many other programs, but I just don't know how to code it...

A way to get a copy of a file with a different name:

FileCopy "[PubDir]Myfile.txt" "[PubDir]NewMyfile.txt"

You can also read the file into a variable (FileRead) and then write this variable to the file with the FileWrite command.

If you are editing a file in your program (for example, in an input field object), then after editing you can transfer a variable with the contents to a new file with the FileWrite command.

If you try to write (FileWrite) to a file with a new name, this file will be created.

 

FileOpenBox "Load File" "Text File|*.txt" "" "[LoadedFile]" ""

the name of a selected file is stored in the variable [LoadedFile]

I want to add "New" to the start of [LoadedFile] and use it as the suggested name for FileSaveBox

But the variable contains the drive letter and directory folder before the actual filename... where do I insert "New"?

@fkapnist

Take a look at the Help in formation for ExtractFileName here ... https://winhelp.visualneo.com/Files1.html#EXTRACTFILENAME

On the same page, there are additional related commands like ...

ExtractFileDrive
ExtractFilePath
ExtractFileExt

fkapnist has reacted to this post.
fkapnist

thanks Gaev.

it is exactly what I was looking for.