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

  • Home
  • SEARCH
  • 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 7963163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:32:56+00:00 2026-06-04T05:32:56+00:00

This is just a sample, but it will help illustrate what I’m trying to

  • 0

This is just a sample, but it will help illustrate what I’m trying to do.

I know how to get the current directory as shown in the script below, and I can can set a file variable.

The problem I’m having is that I can’t figure out how to make it create a folder and put the file in the folder

For example (using the variables below)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var cd = Directory.GetCurrentDirectory();
            Directory.CreateDirectory(cd: \5app\);
            File.Copy(c:\xyz.txt, cd: \5app\xyz.txt

        }
    }
}

I know what I have written above is not correct because vs10 tells me so, but doesn’t give me very much help.

  • 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-04T05:32:58+00:00Added an answer on June 4, 2026 at 5:32 am

    You’re missing a parenthesis and a semicolon, and, especially, arguments of methods Directory.CreateDirectory() and File.Copy() are strings, put them inside quotes:

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                var cd = Directory.GetCurrentDirectory();
                Directory.CreateDirectory(cd + @"\5app\");
                File.Copy(@"c:\xyz.txt", cd + @"\5app\xyz.txt");
            }
        }
    }
    

    MSDN references: Directory.CreateDirectory, File.Copy

    Thanks to Cole Johnson for pointing out that it shouldn’t be @"cd: \5app\".

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

Sidebar

Related Questions

I don't know how to explain this correctly but just some sample for you
This is probably quite simple, but I just don't know how to do this...
Maybe it is just a simple mistake but this thing is driving me crazy.
This might be a simple question but I'm just picking this up so please
Im sure this is pretty simple but I just cant seem to find the
I feel like this might be really simple but I'm just not getting it
I just cannot figure this out, it looks really simple but I'm relatively new
Just starting out, this should be a simple one but I haven't been able
This should be a simple question, but I just can't recall the relevant API.
This should be a simple question, but I just can't seem to figure it

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.