none
Trying to move folders gives me error: "String.cs" not found. Huh? RRS feed

  • Question

  • I'm writing a small program to move every folder from one location to another. When I try to test my code in the debugger, when it attempts to perform the move, a tab opens with the message:

    String.cs not found

    You need to find String.cs to view the source for the current call stack frame.

    The first folder found at the source location is "000_Data", not "String.cs". Searching on Google, other people have reported this same error but with no solution.

    My code:

        Private Sub btnRun_Click(sender As Object, e As EventArgs) Handles btnRun.Click
            For Each foundDir In My.Computer.FileSystem.GetDirectories(lblSrc.Text) ' "lblSrc.Text" contains full path including source foldername.
                bolSkip = False ' reset
                ' Check for existence of folder at target. If it exists, prompt for overwrite. If not, skip.
                strTargetFolder = foundDir.Substring(InStrRev(foundDir, "\"))
                If My.Computer.FileSystem.DirectoryExists(strDestPath & "\" & strTargetFolder) = True Then
                    Dim response = MsgBox("Target folder '" & strTargetFolder & "' already exists!" & vbCrLf & vbCrLf & "Overwrite?", MsgBoxStyle.YesNo)
                    If response = MsgBoxResult.No Then bolSkip = True
                End If
                If Not bolSkip Then
                    lblTarget.Text = strDestPath & strTargetFolder & "\" & strTargetFolder
                    My.Computer.FileSystem.MoveDirectory(foundDir, strDestPath & "\" & strTargetFolder & "\", True)
                End If
            Next
        End Sub


    Error does not occur until MoveDirectory is attempted.

    What is causing this and how do I fix it? TIA


    -*- Mugsy -*-


    Tuesday, November 27, 2018 4:43 PM

Answers

  • Hello,

    From your research did you try "Enable just my Code", restart Visual Studio and then retry debugging? Similarly have you ried Tools-Options-Debugging-Symbols and click 'Empty Symbol Cache' ?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, November 27, 2018 4:56 PM
    Moderator

All replies

  •  Place a Break Point on the line below and debug the application.  When it stops on the break point,  hover your mouse over the different string variables and see what the foundDirstrDestPath,  and strTargetFolder are.  If you place a backslash "\" between strDestPath and strTargetPath,  would it create a valid directory path?

    My.Computer.FileSystem.MoveDirectory(foundDir, strDestPath & "\" & strTargetFolder & "\", True)

     

     You could also place a messagebox or two right before that 'MoveDirectory' line and have it show you the paths,  does it look like they are valid paths?  Do the paths exist on your computer?

    MessageBox.Show(foundDir, "foundDir...")
    MessageBox.Show(strDestPath & "\" & strTargetFolder, "Target Path...")


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, November 27, 2018 4:54 PM
    Tuesday, November 27, 2018 4:53 PM
  • Hello,

    From your research did you try "Enable just my Code", restart Visual Studio and then retry debugging? Similarly have you ried Tools-Options-Debugging-Symbols and click 'Empty Symbol Cache' ?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, November 27, 2018 4:56 PM
    Moderator
  •  PS - Do not forget that you must include the folder name of the source folder on the end of the target folder.  For example...

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim sourcefolder As String = "C:\TestFolder\New folder (2)"
            Dim targetFolder As String = "C:\Test"
    
            'this adds the folder name "New Folder (2)" to the end of the targetFolder, giving you "C:\Test\New Folder (2)"
            Dim destination As String = IO.Path.Combine(targetFolder, IO.Path.GetFileName(sourcefolder))
    
            My.Computer.FileSystem.MoveDirectory(sourcefolder, destination, True)
        End Sub
    


    If you say it can`t be done then i`ll try it

    Tuesday, November 27, 2018 5:47 PM
  • Place a Break Point on the line below and debug the application.

    ...

    You could also place a messagebox or two right before that 'MoveDirectory' line and have it show you the paths


    Thanks for the reply, but I've already done both. All paths & folder names are correct. :(
    Tuesday, November 27, 2018 5:48 PM
  • Place a Break Point on the line below and debug the application.

    ...

    You could also place a messagebox or two right before that 'MoveDirectory' line and have it show you the paths


    Thanks for the reply, but I've already done both. All paths & folder names are correct. :(

     Check what I just said in my last post with the code example,  you must add the source folder's name to the end of the target folder path.

    If you say it can`t be done then i`ll try it

    Tuesday, November 27, 2018 5:49 PM
  • From your research did you try "Enable just my Code", restart Visual Studio and then retry debugging? Similarly have you ried Tools-Options-Debugging-Symbols and click 'Empty Symbol Cache' ?

    .
    Emptying the cache didn't help, but checking "Enable just my Code" in Debugger options resolved the issue (I didn't need to restart VS.)

    Thx.

    PS: Just curious. What was VS trying to do?

    Tuesday, November 27, 2018 5:54 PM
  •  PS - Do not forget that you must include the folder name of the source folder on the end of the target folder.


    Thanks. I caught that once I got the app to run from the debugger. :)

    Tuesday, November 27, 2018 9:53 PM