Sign in to follow this  
Followers 0
Guest yeahns

Exploring Folders

3 posts in this topic

Hi!

I'm having trouble with a piece of code where I want the user to name a folder and pick a place to put the folder. It looks like this:

$var2 = InputBox("", "Folder name", "", "", 200, 125)
$var1 = FileSelectFolder("", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 0)
MsgBox(4096,"", $var1 & "\" & $var2)
DirCreate($var1 & "\" & $var2)
Run("Explorer.exe " & $var1 & "\" & $var2)
Exit

It works fine as long as you put the folder the user named in a sub-folder on the drive, like D:\subfolder, but when the user puts the folder directly on D:\ then I get D:\\ and the "Run("Explorer.exe " & $var1 & "\" & $var2)" does not open the recently created folder.

I'm probably doing a silly mistake but what would be the best way to solve this since I don't know if the user is gonna to put in a subfolder or directly on a drive?

Greatful for any help :)

Kind regards

Jens

Share this post


Link to post
Share on other sites



jens,

you could test if the $var1 ends with a \ and then remove it... like this:

$var2 = InputBox("", "Folder name", "", "", 200, 125)
$var1 = FileSelectFolder("", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 0)
if StringRight($var1,1) = "\" then $var1=StringTrimRight($var1,1)
MsgBox(4096,"", $var1 & "\" & $var2)
DirCreate($var1 & "\" & $var2)
Run("Explorer.exe " & $var1 & "\" & $var2)
Exit

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Excellent!

I was looking for parameters in the Run command that could handle the problem, but using trim takes care of it.

Tank you JdeB!

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  
Followers 0