I ran across a problem today that Im not sure how to correct.
My program loads a database based on the path.
In Windows I had a user that got errors every time he loaded
my program. Well a long story short I found he had his system
user name (Windows) as S&S. This caused my program to
crash. His path looked something like C:\Users\S&s\AppData\ and so on.
The program crashed with an error of cant find C:\Users\s
It drops off the whole folder path after the &
Is there a way to get around this if a user uses these types of characters
for a system name ?
Sorry I miss spoke, The routine crashes trying to delete files in a folder, not loading a database.
Here is some code and comments where it screws up.
The path gets lost with the shell command.
if theFolder = nil or not theFolder.Exists() then
return 0
end if
///// The path is correct at this point: TheFolder = C:\\Users\\S&S\\AppData\\Roaming\\TheUltimateCampgroundLogMW\\TempPictures\\
Dim theShell As New Shell
#If TargetWin32
theShell.Timeout = - 1
///////// This is where the path will screw up in the next step.
///////// While step debugging when it hits the shell execute it drops part of the path as shown.
//////// The ERROR is as shown:
//////// Could Not Find C:\\Users\\S
//////// The system cannot find the path specified.
theShell.Execute "DEL /f/s/q " + theFolder.ShellPath + "\\*.*" //<<<<< It ERRORS here
#Else
theShell.Execute "rm -f " + theFolder.ShellPath + "/*.*"
#EndIf
The path is still correct at this point: TheFolder = C:\Users\S&S\AppData\Roaming\TheUltimateCampgroundLogMW\TempPictures\
You need to Quote your shellpath. This C:\Users\S&S\AppData\Roaming\TheUltimateCampgroundLogMW\TempPictures\. needs to be “C:\Users\S&S\AppData\Roaming\TheUltimateCampgroundLogMW\TempPictures\.”. In Windows any non-standard characters require the path to be quoted - just like having a space in the path.