Console.Readline doesn't read correctly strings with spaces
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Console.Readline doesn't read correctly strings with spaces

  1. #1
    Join Date
    May 2013
    Posts
    4

    Console.Readline doesn't read correctly strings with spaces

    Hi,
    In the following code, I drag into the window a text file, but if the file name contains a space, then the name is not inserted correctly into path string.

    What is the problem?

    If the text file name contains no spaces, then it is read OK into path.

    public static void Main(string[] args)
    {
    string path, pathString2;

    if (args.Length == 0)
    {
    Console.WriteLine("please drag the txt file to the console\n");
    path = Console.ReadLine();
    }

  2. #2
    Arjay's Avatar
    Arjay is online now Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,255

    Re: Console.Readline doesn't read correctly strings with spaces

    It has to do with the dde interaction with the console window. Honestly, I'm surprised you are getting even a partial path.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center