none
I REALLY NEED YOUR TWO CENTS ABOUT: The Microsoft.VisualBasic.FileIO namespace RRS feed

  • Question

  • I cannot use "My" dot anything

    I have 2017 Visual Studio Community and am working on a Visual Basic program.

    Imports System

    Imports System.IO

    Imports Microsoft.VisualBasic

    BUT I CANNOT GET TO The Microsoft.VisualBasic.FileIO namespace

    which contains types that support the My file system object in Visual Basic.

    WHAT AM I DOING WRONG? I AM SECONDS AWAY FROM PULLING THE PLUG AND ENDING IT ALL!

    Dave.

    Tuesday, May 1, 2018 9:15 PM

All replies

  • I cannot use "My" dot anything

    Please don't shout.

    Have you added a reference to Microsoft.VisualBasic.dll?

    Please see: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/namespaces/how-to-use-the-my-namespace

    The Imports statement does not add the reference - Imports simply allows you to refer to the namespace without using the full name.

    Tuesday, May 1, 2018 9:36 PM
  • Please provide your code using "My.".

    Ashidacchi -- http://hokusosha.com/

    Tuesday, May 1, 2018 9:37 PM
  • What template did you choose when you created the new project?

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Tuesday, May 1, 2018 9:59 PM
    Moderator
  • I really appreciate all comments and all the help.

    Here is my current situation:

    1. I added a Reference, browsed to Microsoft\Framework\.NET Framework\v4.5.1\MicrosoftVisualBasic.dll

    2. I am working on a VB Console App that is trying to write a BYTE array to disk using

         IO.File.WriteAllBytes(dat3, {buffer(1)}) 
         because I CAN access System.IO.File.WriteAllBytes (with NO append Boolean 3rd parameter)

    3. But since I need to append also -- I need to access

         My.Computer.FileSystem.WriteAllBytes (with the Append Boolean) 
         i.e. My.Computer.FileSystem.WriteAllBytes(dat3, {buffer(1)}, True)

    Bottomline -- I added the VB Reference, but still cannot access the My.Computer libraries.
    So I am pulling out my long sword and am getting into the traditional position.

    Wednesday, May 2, 2018 1:36 PM
  • You don't need to set a reference. You probably took a .Net Core console project. I do that myself also sometimes by mistake. 

    You need the .Net Console project. 


    Success
    Cor

    Wednesday, May 2, 2018 2:33 PM
  • This is the closest thing I can think of... that's why I asked what template you used to create the project.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, May 2, 2018 3:05 PM
    Moderator
  • Here is my current situation:

    1. I added a Reference, browsed to Microsoft\Framework\.NET Framework\v4.5.1\MicrosoftVisualBasic.dll

    2. I am working on a VB Console App that is trying to write a BYTE array to disk using

         IO.File.WriteAllBytes(dat3, {buffer(1)}) 
         because I CAN access System.IO.File.WriteAllBytes (with NO append Boolean 3rd parameter)

    3. But since I need to append also -- I need to access

         My.Computer.FileSystem.WriteAllBytes (with the Append Boolean) 
         i.e. My.Computer.FileSystem.WriteAllBytes(dat3, {buffer(1)}, True)

    Bottomline -- I added the VB Reference, but still cannot access the My.Computer libraries.
    So I am pulling out my long sword and am getting into the traditional position.

    Wednesday, May 2, 2018 3:15 PM
  • Here is my current situation:

    1. I added a Reference, browsed to Microsoft\Framework\.NET Framework\v4.5.1\MicrosoftVisualBasic.dll

    2. I am working on a VB Console App that is trying to write a BYTE array to disk using

         IO.File.WriteAllBytes(dat3, {buffer(1)}) 
         because I CAN access System.IO.File.WriteAllBytes (with NO append Boolean 3rd parameter)

    3. But since I need to append also -- I need to access

         My.Computer.FileSystem.WriteAllBytes (with the Append Boolean) 
         i.e. My.Computer.FileSystem.WriteAllBytes(dat3, {buffer(1)}, True)

    Bottomline -- I added the VB Reference, but still cannot access the My.Computer libraries.
    So I am pulling out my long sword and am getting into the traditional position.

    This is a duplicate of your post from an hour ago...

    What template did you select when you started the new project?

    As Cor has noted, it is likely you have selected the wrong type of project.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, May 2, 2018 3:31 PM
    Moderator
  • Thank you. Thank you. Thank you.
    Wednesday, May 2, 2018 3:43 PM
  • Thank you. Thank you. Thank you.

    Sounds like that was the issue.

    When using these forums, please close your thread by clicking the "Mark as answer" link at the bottom of one or more relevant posts when your issue has been resolved.

    Thanks!


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, May 2, 2018 3:54 PM
    Moderator