Jump to content

Default Save Folder


Eambo
 Share

Recommended Posts

Hi again everyone!

Thanks to those who helped me in my other post, I'm making awesome progress. I'm stuck on something that's probably very simple, and I hope someone can help :-)

Let's say for example, I have this:

$FileSaveLocation = FileSaveDialog("Save File", $DefaultFolder & $DownloadLine, "All (*.*)")

To further this example:

$DefaultFolder = C:\Program Files\

$DownloadLine = DownloadFolder

So essentially the above should default to C:\Program Files\DownloadFolder.

This doesn't seem to be working so well for me. Have I done something very silly? Any advice or criticism is welcome! :-)

Link to comment
Share on other sites

Hi again everyone!

Thanks to those who helped me in my other post, I'm making awesome progress. I'm stuck on something that's probably very simple, and I hope someone can help :-)

Let's say for example, I have this:

$FileSaveLocation = FileSaveDialog("Save File", $DefaultFolder & $DownloadLine, "All (*.*)")

To further this example:

$DefaultFolder = C:\Program Files\

$DownloadLine = DownloadFolder

So essentially the above should default to C:\Program Files\DownloadFolder.

This doesn't seem to be working so well for me. Have I done something very silly? Any advice or criticism is welcome! :-)

$DefaultFolder = "C:\Program Files\"

$DownloadLine = "DownloadFolder"

now it'd work :x

EDIT: to check if you've declared something correctly, use a msgbox

$DefaultFolder = "C:\Program Files\"
$DownloadLine = "DownloadFolder"

$test = $DefaultFolder $ $DownloadLine
msgbox(0,"",$test)

and see what pops up ^.^

Edited by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

I'm actually slightly confused.

It's popping up the SaveFileDialog. If I press cancel, it downloads the file to the correct directory. I guess a nasty little workaround would be...

Is there a way I can automate the 'cancel' pressing before the user gets a change to change the default file directory? :-)

I need to do a bit more testing, but from what I can see this is happening O.O

Edit: Nevermind, I take it back. It's making a file, however there's nothing in it O.o

So what I'm experiencing right now is that for some reason it's defaulting to what seems to be the @ScriptDir. There's definitely a trailing backslash in there, so I don't know why it's doing that...

Edited by Eambo
Link to comment
Share on other sites

Okay, I'm messing with my code and need to stop it :-)

Essentially I've got this:

- An Error Log

- Code that extracts this error log

- The error log then points to a website to download a replacement file

So here's an example:

[ERROR] C:\Program Files\Files\Broken.reg

This then gets converted to a web address as follows:

www.downloadfix.com/Files/Broken.reg

So we'll say my default folder is 'Files'. I'm running my script from there. What I want the script to do is to pre-populate the download so they literally only have to press save. So it should be saving as "Broken.reg" in the /Files folder.

I have this code:

$DefaultFolder=@ScriptDir

$DownloadFolder = $DefaultFolder & "\" & $DownloadLine

$DownloadLine = the extracted error message.

From what I can see it should be working, I've got a msgbox that shows it as C:\Program Files\Files\Broken.reg

But when it gets to the 'save' prompt, it's in the @ScriptDir, and the text box for save is blank. Which means the user would have to manually navigate to the folder to save it.

I either want this prepopulated, or I simply want it to download - no prompt. Is there a way to do either of these?

Thanks everyone for your help :-)

Link to comment
Share on other sites

Do you mean that the default file name should (broken.reg) should be in the text box?

Or should C:\Program Files\Files\Broken.reg be in the text box?

On that note, in your line you never specified a default file name. You did not have enough options listed to set the default name. It should have something like this

$FileSaveLocation = FileSaveDialog("Save File", $DefaultFolder & $DownloadLine, "All (*.*)", 16, $DownloadLine)
That would give the user a prompt like in the attached picture.

Also, if the directory that you have for initial directory does not exist BEFORE the FileSaveDialog() function, the @ScriptDir will be the initial folder that is selected. So make sure that "C:\Program Files\Files" exists before using that function.

post-8593-0-33579500-1295487840_thumb.pn

Edited by Varian
Link to comment
Share on other sites

Hardcoding "C:\Program Files\" is bad. What if the user is on a x64 OS? What if they don't have a English Windows? (Program Files is localized)

Use @ProgramFilesDir or something instead.

Link to comment
Share on other sites

Hardcoding "C:\Program Files\" is bad. What if the user is on a x64 OS? What if they don't have a English Windows? (Program Files is localized)

Use @ProgramFilesDir or something instead.

Sorry Admiral, this was more of a generic example, it's not actually what I'm programming :-) I'm using @ScriptDir and working from there :-)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...