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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:00:37+00:00 2026-06-03T16:00:37+00:00

I have a C#.Net console app code that transfers files between linux and windows

  • 0

I have a C#.Net console app code that transfers files between linux and windows ftp servers.

The code’s behavior is that I automatically open a console to display status of the file transfer. While transferring files to and from the windows server, I need to display an indicator that the file transfer is on-going (using symbols that look like they are moving or turning) . These symbols are as follows : “|” –> “/” –> “-” –> “\” –> “|”

There had been no problem displaying the said “indicator/symbols” in C#.Net using the following codes :

ProcessStartInfo PSI = new ProcessStartInfo("CMD.exe", "/C [here is the call to psftp / ftp scripts]"); 

String SymbolChar = "|";
Process proc = Process.Start(PSI); 

        while (true)
        {
            Thread.sleep(20);


            if (proc.HasExited)
            {
                Console.WriteLine("\b-> Done\n");
                break;
            }
            else
            {
                SymbolChar = NextChar(SymbolChar);
                Console.Write("\b{0}", SymbolChar);
            }
        }
        StreamReader srError = proc.StandardError;
        StreamReader srOutput = proc.StandardOutput;

//method used to animate status during process
    private static String NextChar(String sCurrentChar)
    {
        String sTempChar = "";

        if (sCurrentChar.equals("|")) {
            sTempChar = "/";
        }
        else if (sCurrentChar.equals("/")) {
            sTempChar = "-";
        }
        else if (sCurrentChar.equals("-")) {
            sTempChar = "\\";
        }
        else if (sCurrentChar.equals("-")) {
            sTempChar = "\\";
        }
        else if (sCurrentChar.equals("\\")) {
            sTempChar = "|";
        }

        return sTempChar;
    }

My problem started when I converted the said codes into java using the following :

String sParam = "bash " + [here is the call to psftp / ftp scripts];
String cmd[] = {"/bin/bash","-c",sParam};
Process proc = Runtime.getRuntime().exec(cmd);

Above code is perfectly working.
Problem is I don’t know how to display the “animated” characters anymore.
I suddenly don’t know (and I badly need help on) how to convert this :

Process proc = Process.Start(PSI); 

        while (true)
        {
            Thread.sleep(20);


            if (proc.HasExited)
            {
                Console.WriteLine("\b-> Done\n");
                break;
            }
            else
            {
                SymbolChar = NextChar(SymbolChar);
                Console.Write("\b{0}", SymbolChar);
            }
        }

Do you have any idea as to what I can use for the line “if (proc.HasExited)” in java so that I could move forward?

Sorry for the long explanation.
I really, really need help.

Thank you very much in advance!

  • 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-03T16:00:38+00:00Added an answer on June 3, 2026 at 4:00 pm

    You could use ‘Process.exitValue()’ and catch the Exception (it will throw an Exception if the process is not done yet). If the value is 0 the process exited normally. However this is rather ugly IMHO.

    The only ‘proper’ way I know in Java to wait for a process to finish is to have the current Thread block until the Process is done with ‘Process.waitFor()’.

    This would however require a different thread to display your progress animation since your current thread is blocked and waiting for the Process to finish.

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

Sidebar

Related Questions

Help me, Stackoverflow! I have a simple .NET 3.5 console app that reads some
I have a console app built on .NET 4 that uses the HttpClient library
I have a .NET console application that needs to generate some HTML files. I
I have a console app on the server that I need to run between
I have a console app that watches a folder (Manual code... not using the
We have a .NET console app that has many foreground threads. If we kill
I have a .NET console app running on Windows Server 2003, as a scheduled
I have a .net console app that launches excel. I have it working on
My scenario is that I have a .net application (let's say a Console App)
So i have this code in a .NET 2.0 console app: [DllImport(kernel32.dll)] private static

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.