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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:31:01+00:00 2026-06-09T23:31:01+00:00

C# win Forms hi. CMD windows keeps saying the system cannot find file specified

  • 0

C# win Forms

hi. CMD windows keeps saying “the system cannot find file specified”
If I type in the command in CMD window “copy /b myfile.txt test.txt” it works :S

btw.: is there a way to actually see the command getting executed in the CMD window ?

    public void OutputBtn_Process_Click(object sender, EventArgs e)
    {
        foreach (FileInfo fi in listBox1.Items)
        {
            Process process1 = new Process();
            process1.StartInfo.UseShellExecute = false;
            process1.StartInfo.Arguments = "copy /b \""+fi.Name+"\"test.txt";
            //process1.StartInfo.LoadUserProfile = true;
            process1.StartInfo.FileName = "cmd.exe\"/k";
            process1.StartInfo.WorkingDirectory = Path.GetDirectoryName(fi.FullName);
            process1.Start();

            process1.Dispose();
            process1.Close();
        }
    }
  • 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-09T23:31:02+00:00Added an answer on June 9, 2026 at 11:31 pm

    The /K is an argument and should be in the Arguments property not on the FileName property
    (and, of course L.B. is right when he suggests to put a space in front of test.txt)

    process1.StartInfo.Arguments = "/k copy /b \""+fi.Name+ "\" test.txt"; 
    process1.StartInfo.FileName = "cmd.exe"; 
    

    By the way, your code, as written, loops on a listbox and, in each loop, re-write the file test.txt with the contents of the current FileInfo item. In this way, the last file in the list will be the one who its content is copied to test.txt. Is this logic correct?

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

Sidebar

Related Questions

We have Win Forms application uses the 3rd party windows native controls. Can these
The Windows console interface (think cmd window) is to the user a pretty simple
I have a win forms application written in C# which has a resource file,
I developed a win forms app targeting .net 2.0. All of this is in
How to redirecting from win forms to web forms ?
Scenario I have a C# Win Forms App, where the Main Form contains a
How to design a beautiful win forms UI.(a little like MSN message client) I
I am writing a simple win forms app in C#. There is a method
I'm developing a .net 3.5 Win Forms program and I've run into an interesting
my team have built many tools for our project using win forms and Visual

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.