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 8265523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:50:14+00:00 2026-06-08T04:50:14+00:00

In Visual Studio (VB.NET), I want to open a file and read the contents

  • 0

In Visual Studio (VB.NET), I want to open a file and read the contents into a string. It’s easy enough when the file is in a known location on disk, since you can reference it as C:\Windows\foo.txt or whatever. Is there any way to refer to files based on their location in the solution? For example, MySolution\MyProject\MyFolder\foo.txt. The file to read will be a SQL file, so there won’t be any code objects in it to work with.

I use a whole bunch of different solutions that are stored in various places on disk, so I really don’t want to have to deal with the file system directly. Any ideas?

  • 1 1 Answer
  • 0 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-06-08T04:50:16+00:00Added an answer on June 8, 2026 at 4:50 am

    If you go to the file properties for the file in the solution, you’ll notice that one of the options is “Copy to Output Directory”. You need to set that to either “Copy always” or “Copy if newer”. Once you set that on all the pertinent files and re-build the project, you will notice that all of those files will be copied to the bin\Debug or bin\Release folder (which ever one you were building to) as part of the build process. Now, in your application, you can just assume that they will be in the same directory as your application.

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

Sidebar

Related Questions

We want to split our large asp.net mvc web application into multiple Visual Studio
I want to switch over to Mono from .Net (plus Visual Studio to whatever
I'm writing a standalone application in VB.NET using Visual Studio 2005. I want to
I Use Visual Studio 2010 with ASP.NET 4.0 and IIS7. When I open my
Is it possible to somehow make Visual Studio / ASP.NET open multiple browsers when
I want to debug a ASP.NET application (Custom IHttpHandler) with Visual Studio 2008 and
I'm using Visual Studio 08 and Vb.Net (3.5). I want to call a perl
I'm developing an ASP.NET 2.0 app using Visual Studio 2008. If I want to
I want to install Visual Studio .NET WEB Express, I am forced to install
Using Visual Studio .NET 2003 C++ and the wininet.dll Am seeing many C4995 warnings

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.