JustinReno Posted August 28, 2007 Share Posted August 28, 2007 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... Link to comment Share on other sites More sharing options...
felanor Posted August 28, 2007 Share Posted August 28, 2007 (edited) 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 August 28, 2007 by felanor Check Out My ScriptsFile Property Management - Adjust a file's title, author, subject, etc. Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 28, 2007 Share Posted August 28, 2007 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. Link to comment Share on other sites More sharing options...
JustinReno Posted August 28, 2007 Author Share Posted August 28, 2007 does the same thing. It just saves it as NAME.spf.spf UGH Link to comment Share on other sites More sharing options...
felanor Posted August 28, 2007 Share Posted August 28, 2007 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 Check Out My ScriptsFile Property Management - Adjust a file's title, author, subject, etc. Link to comment Share on other sites More sharing options...
JustinReno Posted August 28, 2007 Author Share Posted August 28, 2007 YAY I WORKED!!! THANK YOU SOOOO MUCH! Link to comment Share on other sites More sharing options...
felanor Posted August 28, 2007 Share Posted August 28, 2007 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 Check Out My ScriptsFile Property Management - Adjust a file's title, author, subject, etc. Link to comment Share on other sites More sharing options...
JustinReno Posted August 28, 2007 Author Share Posted August 28, 2007 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! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now