Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 799381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:07:02+00:00 2026-05-14T23:07:02+00:00

We have to learn VB.NET for the semester, my experience lies mainly with C#

  • 0

We have to learn VB.NET for the semester, my experience lies mainly with C# – not that this should make a difference to this particular problem.

I’ve used just about the most simple way to save a file using the .NET framework, but Windows 7 won’t let me save the file anywhere (or anywhere that I have found yet). Here is the code I am using to save a text file.

Dim dialog As FolderBrowserDialog = New FolderBrowserDialog()
Dim saveLocation As String = dialog.SelectedPath
... Build up output string ...
Try
    ' Try to write the file.
    My.Computer.FileSystem.WriteAllText(saveLocation, output, False)
Catch PermissionEx As UnauthorizedAccessException
    ' We do not have permissions to save in this folder.
    MessageBox.Show("Do not have permissions to save file to the folder specified. Please try saving somewhere different.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch Ex As Exception
    ' Catch any exceptions that occured when trying to write the file.
    MessageBox.Show("Writing the file was not successful.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

The problem is that this using this code throws an UnauthorizedAccessException no matter where I try to save the file. I’ve tried running the .exe file as administrator, and the IDE as administrator.

Is this just Windows 7 being overprotective? And if so, what can I do to solve this problem? The requirements state that I be able to save a file!

Thanks.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:07:03+00:00Added an answer on May 14, 2026 at 11:07 pm

    This code:

    Dim dialog As FolderBrowserDialog = New FolderBrowserDialog()
    Dim saveLocation As String = dialog.SelectedPath
    

    Is giving you the location of a folder. Then you’re trying to save a file with the same name as the folder. Instead, I assume you want to save a file inside that folder:

    Dim saveLocation As String = dialog.SelectedPath
    saveLocation = Path.Combine(saveLocation, "SomeFile.txt")
    

    That will create a file called “SomeFile.txt” inside the selected folder.

    Alternatively, instead of using FolderBrowserDialog to choose a folder, use SaveFileDialog to select the actual file instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn ASP.NET MVC and I hit this problem: I have
I want to learn .NET and I have 2 weeks time of this. I
To learn ASP.net I started building a todo web app(web forms not MVC), this
I have started to learn ASP.NET MVC, and at this time of studying I
I have just started to learn ASP.NET MVC 3 form this book and I
I'm going to learn asp.net by taking a institute coaching. I have background of
I have an Asp.Net background and trying to learn Silverlight. Can you explain, what
i have a vb.net background and trying to learn c# syntax
One day I suspect I'll have to learn hadoop and transfer all this data
I have been following http://learn.iis.net/page.aspx/806/seo-rule-templates/ , which is a nearly perfect guide to creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.