Hello, I would like to make a program which stores its settings in a file, which it then reads out back.
I've already tried a code, but it crashed "No Premissions to Write" I tried on my Desktop, C:/ and on mine external HDD

I tried this code:My.Computer.FileSystem.WriteAllText("C:\TestFolder1\test.txt", "This is new text to be added.",True)

Please, help me.

Do you get the same problem if you just try copying a file to that location using Explorer? Your code will write text to a file as long as you have permission.

Of course, i have premission to write at C:/ G:/ My Desktop and so on (Admin account)

Run the Application as Admin.
___________________________________________________________
You Can Also make the default run as Admin in VB.Net
• How?
Ans: Go to "My Project" through Solution Explorer > Application > Then Click on the "View Windows Settings"
And the Find the following Line:

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

And Replace the Whole line with this Code:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

What we did is
Change the user Permission.
"asInvoker" is the User/guest can use this, But while saving any file to the Windows installed Drive ( "C" ) then,
You will get the error:

"Access is Denied on C:\..." .

So We make the Admin user by adding the code:
"requireadministrator" so that the error msg will stop messaging you.

If you get still errors, then use the function:

 Try
 'your code will be here.     
 catch As Exception
 msgbox(ex.message)
 End Try

and then post that msg so that I can Help Further if I can.

I guess you got the solution,
if not then just please elaborate your Doubt,
According to me what your error msg should be resolve as I comment above,
If more then Please use the "TRY" Fun:
And add this code msg in your doubt.

And please elaborate how much you can.
        CustTextWriter = IO.File.CreateText("Your path here")

        Dim write As String = "Write your text here"       

        CustTextWriter.WriteLine(write)


        CustTextWriter.Flush()
        CustTextWriter.Close()

As you type this code:

My.Computer.FileSystem.WriteAllText("C:\TestFolder1\test.txt", "This is new text to be added.",True)

I think so you can't save your file.
as there may be some following reasons:
• The Folder not present in drive "C" (TestFolder1)
• As this is the Windows Drive, you should have Administrator Permission.
• Or may be the mistak in code.
• If you are creating the Notepad, And want to add the save file button code.
then You can use the "Save File Dialog"

Any Doubt???