Jump to content
Sign in to follow this  
JustinReno

File Extention issue in a notepad program

Recommended Posts

JustinReno

I have just about finished my notepad program. But i'm haveing some issues with making a file extention with it.

CODE

FileWrite($FileSaveDialog&".SPF", $Encrypt)

It adds the extention like i want it to, but if i save it again it doubles the extention, (testfile.spf.spf) Any ideas how to stop this? i tried file delete and then rewrite it but it didnt work...

Share this post


Link to post
Share on other sites
felanor

I have just about finished my notepad program. But i'm haveing some issues with making a file extention with it.

CODE

FileWrite($FileSaveDialog&".SPF", $Encrypt)

It adds the extention like i want it to, but if i save it again it doubles the extention, (testfile.spf.spf) Any ideas how to stop this? i tried file delete and then rewrite it but it didnt work...
Hey Justin,

I too, had a similar issue with the silly double extensions. What I would recommend is testing to see if the filename has a double extension. I will post some code that might help.

$filename = FileSavedDialog("DIALOG TITLE", "INITIAL DIRECTORY", "Encrypted Text Files (*.spf)")
$filename = StringReplace ($filename, ".spf.spf", ".spf")
FileWrite ($filename, $Encrypt)

You may need to massage that a bit, but that should get you well on your way.

If you have any questions, let me know

~Felanor

Edited by felanor

Share this post


Link to post
Share on other sites
Richard Robertson

You should check the filename from the dialog before you add the extension. If the dialog is set up with a certain option, it will add the extension when a file is selected.

Share this post


Link to post
Share on other sites
JustinReno

does the same thing. It just saves it as NAME.spf.spf

UGH

Share this post


Link to post
Share on other sites
felanor

does the same thing. It just saves it as NAME.spf.spf

UGH

Hey Justin,

This here should do the trick.

$FileSaveDialog = FileSaveDialog("TITLE", "DIRECTORY", "filter(*.spf)")
$FileSaveDialog &= ".spf"
$FileSaveDialog = StringReplace ($FileSaveDialog, ".spf.spf", ".spf")
FileWrite ($FileSaveDialog, $Encrypt)

Note, you will need to make sure that you setup the FileSaveDialog with the actual values. Also, you will want to update the FileWrite command to no longer include the extra ".spf" as that was done just after choosing the file from the dialog box.

If you have any more questions, let me know.

~Felanor

Share this post


Link to post
Share on other sites
JustinReno
YAY I WORKED!!! THANK YOU SOOOO MUCH! :)

Share this post


Link to post
Share on other sites
felanor

YAY I WORKED!!! THANK YOU SOOOO MUCH! :)

Did you still need help with that problem? I think I was able to figure out why you were getting the garbled characters.

Anyways,

As you did not use the FileOpen command to open your file for writing, when you used FileWrite, it defaulted to append mode, meaning any data you add after the fact will not encrypt properly.

What you need to do is replace the following section of your save button.

FileWrite ($FileSaveDialog, $Encrypt)

With this code here.

$filename = FileOpen($FileSaveDialog, 2)
FileWrite($filename, $Encrypt)
FileClose($filename)

This should let you save your files properly. I tried it after using the full source you had previously provided, but is not gone, and it seems to work ok.

Any further questions, all you have to do is ask.

~Felanor

Share this post


Link to post
Share on other sites
JustinReno

Thx, yeah, i figured it out, so then i deleted the post, THANK YOU. I just put a file delete after the save dialog opens. and it works good, i'm going to put it in the example forums now, with a new 64 bit, Mixed Case, Numbers, Punctuation and no similar character type of password to encrypt the text files, with stringencrypt on level 3. so it works well, without it slowing down, and without the encrypted files being too too big. Thx for all of your help! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×