none
problem streamwriter windows 10 RRS feed

  • Question

  • hello

    When I write anything in a file on a partition C, it tells me that you do not have permission to write, even though I have the administrative in the project. And bummer on Windows 10 only


    Monday, September 2, 2019 9:40 PM

Answers

  • Hello,

    What happens if you try this to a folder such as your Documents folder which you should have rights too. Also, it is unwise to write to a folder directly off the root of the drive.


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Because I want to write in a file hosts

    File hosts on windows 10 local drive ??? not enough details to understand what you are talking about.

    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    I want to write this path  C:\Windows\System32\drivers\etc  in a file hosts

    See the following

    http://www.vbforums.com/showthread.php?675913-RESOLVED-File-access-denied&p=4152294&viewfull=1#post4152294


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, September 3, 2019 12:36 AM
    Moderator
  • Hi,

    I'm afraid you forget "sw.Close" after "sw.Write".
    Dim filename As String = "C:\Test\StreamWriter.txt"
    Dim sw As New System.IO.StreamWriter _
    	(filename, False, System.Text.Encoding.UTF8)
    ' ----
    sw.Write(Me.TextBox1.Text)
    sw.Close()   ' -- Do you Close StreamRiter?
    When I made "sw.Close" commented and execute code (without Closing) twice.
    First execution has been done normally, but the same exception occurred at the second time.  

    After "sw.Write", the written file is locked, so we should close it.

    Regards

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html


    Tuesday, September 3, 2019 1:14 AM

All replies

  • Hello,

    What happens if you try this to a folder such as your Documents folder which you should have rights too. Also, it is unwise to write to a folder directly off the root of the drive.


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, September 2, 2019 9:54 PM
    Moderator
  • Hello,

    What happens if you try this to a folder such as your Documents folder which you should have rights too. Also, it is unwise to write to a folder directly off the root of the drive.


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Because I want to write in a file hosts
    Monday, September 2, 2019 10:13 PM
  • Hello,

    What happens if you try this to a folder such as your Documents folder which you should have rights too. Also, it is unwise to write to a folder directly off the root of the drive.


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Because I want to write in a file hosts
    File hosts on windows 10 local drive ??? not enough details to understand what you are talking about.

    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, September 2, 2019 10:51 PM
    Moderator
  • Hello,

    What happens if you try this to a folder such as your Documents folder which you should have rights too. Also, it is unwise to write to a folder directly off the root of the drive.


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Because I want to write in a file hosts

    File hosts on windows 10 local drive ??? not enough details to understand what you are talking about.

    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    I want to write this path  C:\Windows\System32\drivers\etc  in a file hosts
    Monday, September 2, 2019 11:24 PM
  • Hello,

    What happens if you try this to a folder such as your Documents folder which you should have rights too. Also, it is unwise to write to a folder directly off the root of the drive.


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Because I want to write in a file hosts

    File hosts on windows 10 local drive ??? not enough details to understand what you are talking about.

    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    I want to write this path  C:\Windows\System32\drivers\etc  in a file hosts

    See the following

    http://www.vbforums.com/showthread.php?675913-RESOLVED-File-access-denied&p=4152294&viewfull=1#post4152294


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, September 3, 2019 12:36 AM
    Moderator
  • Hello,

    What happens if you try this to a folder such as your Documents folder which you should have rights too. Also, it is unwise to write to a folder directly off the root of the drive.


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Because I want to write in a file hosts

    File hosts on windows 10 local drive ??? not enough details to understand what you are talking about.

    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    I want to write this path  C:\Windows\System32\drivers\etc  in a file hosts

    See the following

    http://www.vbforums.com/showthread.php?675913-RESOLVED-File-access-denied&p=4152294&viewfull=1#post4152294


    Please remember to mark the replies as answers if they help and unmarked 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.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    i test code not work windows 10 work only windows 7 only i need fix code windows 10
    Tuesday, September 3, 2019 1:01 AM
  • Hi,

    I'm afraid you forget "sw.Close" after "sw.Write".
    Dim filename As String = "C:\Test\StreamWriter.txt"
    Dim sw As New System.IO.StreamWriter _
    	(filename, False, System.Text.Encoding.UTF8)
    ' ----
    sw.Write(Me.TextBox1.Text)
    sw.Close()   ' -- Do you Close StreamRiter?
    When I made "sw.Close" commented and execute code (without Closing) twice.
    First execution has been done normally, but the same exception occurred at the second time.  

    After "sw.Write", the written file is locked, so we should close it.

    Regards

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html


    Tuesday, September 3, 2019 1:14 AM