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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:01:53+00:00 2026-06-12T14:01:53+00:00

Question is rather simple, and somewhat pointless I understand, but still… Database is on

  • 0

Question is rather simple, and somewhat pointless I understand, but still…

Database is on the server, of course, and I need an action that will when initiated grab that file from database and save it to a folder that is in my AppSettings["Active"] configuration property.

Basically,

public ActionResult Activate(int id)
{
    Project project = db.Projects.Find(id);

    var activeProjectData = project.XML; // project.XML returns byte[] type
    //For download (not in this method of course) i'm using something like return File(activeProjectData, "text/xml"); and that works ok

}

Now I want to save that file to AppSettings["Active"] path. Not to sure how to go about it. I’ve tried using System.IO.File.Create() but that didn’t quite turn out well.

Any help is appreciated.

  • 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-12T14:01:55+00:00Added an answer on June 12, 2026 at 2:01 pm

    Simply create a FileStream and use it to write the data:

    string fileName = ConfigurationManager.AppSettings["Active"];
    using(var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write) )
    {
        fs.Write(project.XML, 0, project.XML.Length);
    }
    

    If you don’t need more control than that, there is a simple helper method on the File class:

    File.WriteAllBytes(fileName, project.XML);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather simple question that I could normally debug myself, but I
The question is rather simple, but my brain boils :((( I know, that i
I think that's a rather simple Question but I don't get it the way
my question is rather simple, if you have an pure virtual class (interface) but
I think its a rather simple question but I couldn't really find an answer
Rather a simple question. But the implications are vast. Over the last few weeks
Question is rather simple but I couldn't find nice & clean solution to my
The question is rather simple. I know that there is SQLite. There is Core
My question is rather simple, but I am stuck. How can I choose the
My question is rather simple, but I couldn't find an answer, could be because

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.