Jump to content

FilaPath problem


Recommended Posts

Hi there everyone...

I have a litle problem with the FileSelectFolder function.

I made a backup program that is asking you where you want to save the backup fiele. Everithing works great there.But when I chose a path like a USB key ex: F:\ it works ok.

If I chose the desktop for example I get ex: C:\Documents and Settings\USERNAME\BureauBACKUPFILE without the "\". If I want it to return the full path with the "\" I put a \ in front of my variable. Ok It works on the desktop but no more on the USB Key.. It gives me ex: F:\\BACKUPFILE

How can i check with StringRegExpReplace or StringRegExp to delete the \ if it exists ?

Here is the part of the scrypt:

Local $chemin = FileSelectFolder("Veuillez choisire l'endroit pour copier la sauvegarde","")

    If StringInStr($chemin,"\\") Then
        $Dest = $chemin & $backupName
    Else
        $Dest = $chemin & "\" & $backupName
    EndIf

Thanks a lot for your help

Link to comment
Share on other sites

Ok I found my problem and I dit'it like this

Local $chemin = FileSelectFolder("Veuillez choisire l'endroit pour copier la sauvegarde","")
    $Dest = $chemin & "\" & $backupName
    
    If StringInStr($Dest,"\\") Then
        $Dest = $chemin & $backupName
    Else
        $Dest = $chemin & "\" & $backupName
    EndIf

but how can I make'it simpler or use the StringRegExp

Link to comment
Share on other sites

Local $chemin, $Dest, $backupName = "BureauBACKUPFILE"
$chemin = FileSelectFolder("Veuillez choisire l'endroit pour copier la sauvegarde","")
If StringRight($chemin, 1) <> "\" Then $chemin &= "\"
$Dest = $chemin & $backupName

Or

Local $chemin, $Dest, $backupName = "BureauBACKUPFILE"
$chemin = FileSelectFolder("Veuillez choisire l'endroit pour copier la sauvegarde","")
$chemin &= "\"
$Dest = StringReplace($chemin & $backupName, "\\", "\")
Edited by smashly
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...