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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:23:47+00:00 2026-05-12T08:23:47+00:00

I have a C# project say MyProject.csproj located at C:\Projects\MyProject\. I also have files

  • 0

I have a C# project say MyProject.csproj located at “C:\Projects\MyProject\”. I also have files that I want copied into the output directory of this project. But, the files are at the location “C:\MyContentFiles\”, i.e. they are NOT within the project cone. This directory has sub-directories as well. The contents of the directory is not managed. Hence I have to include all what is under it.

When I include them as ‘Content’ in the project, they are copied, but the directory structure is lost. I did something like this:-

<Content Include="..\..\MyContentFiles\**">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

How do I copy these files/directories recursively into the output directory of the project with the directory structure preserved?

  • 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-05-12T08:23:47+00:00Added an answer on May 12, 2026 at 8:23 am

    You need to add file as a link:

    1. Right click on the project in VS.
    2. Add -> Existing Item…
    3. Find the file.
    4. Select it and.
    5. Add as a Link (drop down in the Add Button in the dialog).
    6. Open the properties of the file and set “Copy to Output Directory” to “Copy always”.

    BUT You cannot do it for the directory tree.
    Instead you need to write post-build task for that. This is a sample that will get you stared.

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

Sidebar

Related Questions

I have a directory full of scripts (let's say project/bin ). I also have
Let's say I have a project that is a class library. I have a
say that i have a project which lies in a folder called 'bin', and
I say project file in the loosest sense. I have a few python projects
Let's say that my project has a main class. I'd love to have public
Let's say I have a project where I've already run CMake in .build directory:
I have a project (say myproject) in which I have hosted a CXF RESTful
Say, I have files foo.js and bar.css in my project. There is a :find
Let's say I have one project with the following POM: <groupId>com.mine</groupId> <artifactId>coreJar</artifactId> <packaging>jar</packaging> <version>0.0.1-SNAPSHOT</version>
Say I have a project in a git repository. The project has a branch

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.