CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012

    Sting with Quotes Issue


    I have been trying for hours to understand how to escape with double quotes and have had no luck.

    I need to pass a string to a process.start arguments line like this.

    String DF = @"C:\temp\test\backups\";

    But need to add double quotes only to the front side of this line, like this when executed:


    And not like this:


    And cannot figure out how to do it.

    I have tried "\""

    Any help would be great thanks,


  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004

    Re: Sting with Quotes Issue

    var df = @"C:\temp\test\backups\";            
    // var df = "\"" + @"C:\temp\test\backups\";
    if (df[0] != '\"')
        df = "\"" + df;
    That being said, want you probably want to do is form the complete portion of the string that needs to be double quoted and then write a method that checks and quotes the ends as necessary. This ends up being easier to follow than quoting the beginning forming the rest of the string and then quoting the end (plus the method is reusable).

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.