Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FolderBrowserDialog's updated, but memvar isn't

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
568
US
Colleagues,
The subject line may sound cryptic, but I dunno how else to describe this problem:

2023_04_12_09_37_ASCII_Text_Search_GetDirDialogNotUpdated_qf5jgx.jpg


The "Get Dir" dialog correctly returns the selected path (as String), but the memvar lsSel[ected]Dir is not updated!
Here's the code:

Code:
'====================================================================================================================================
Private Sub cmdSrcDir_Click(sender As Object, e As EventArgs) Handles cmdSrcDir.Click
'====================================================================================================================================
Dim lsSrcDir As String = AddBackSlash(Me.txtSrcDir.Text.Trim()), lnRet As DialogResult = Forms.DialogResult.None, lsSelDir As String
objDirDlg.SelectedPath = txtSrcDir.Text

lnRet = objDirDlg.ShowDialog()

If Not (lnRet = Forms.DialogResult.OK) Then
	Directory.SetCurrentDirectory(lsSrcDir)
	Exit Sub
End If

lsSelDir = AddBackSlash(objDirDlg.SelectedPath)

If lsSelDir.Length = 0 Then
	Directory.SetCurrentDirectory(lsSrcDir)
	Exit Sub
End If

txtSrcDir.Text = lsSelDir

What am I missing or doing wrong?
OR
Could that be that dot in the last subdir's name, "C:\Ilya_Docs\2023_Tax_Forms\2023 Puerto Rico\480.7c_2022_informativo_files"? Coz when I selected some other dir (just alpha-numeric+underscores, no dot) it worked correctly.
Please advise!

Regards,

Ilya
 
I found the "culprit!"

Code:
If Path.GetFileName(tsPath) <> "" And [b][u]Path.GetExtension(tsPath) <> ""[/u][/b] Then 'Path + File name? Strip off that latter
	lsPath = tsPath.Replace(Path.GetFileName(tsPath), "")
Else
	lsPath = tsPath
End If

Obviously, Path.GetExtension() looks for the dot from the right end and, if found, takes everything beyond this dot as extension.
My function, then "decides" that the substring on the right from the last backslash presents the file name... and "the rest is history".
However!...
This dot in the directory name presents another challenge: when present in the rightmost part of the path, Path.GetFileName() "thinks" it's a file name!

2023_04_13_09_03_Path_Join_vs_AddBackSlash_jweyyi.jpg


Aw, scheise!

[banghead]

I wish chars like dot in a directory name were "verboten"!

"Yesterday, all my troubles seemed so far away...
Now it looks as though they're here to stay
And now I long for yesterday..."
(Apologies, Sir Paul! :) )

Well, "a man gotta do what a man gotta do!"

Thank you, Strong M., for pointing me onto the right direction!
Tapadh leat!

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top