Results 1 to 6 of 6

Thread: [RESOLVED] another string question for C#

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Resolved [RESOLVED] another string question for C#

    I more or less finished the code conversion from my vb app to my c# app

    however as allways there are a few weird bugs to work out


    on i noticed today was that my filepath information has extra \\ added to the file path name

    i assume that its becuase \ is an escape charter but how can add it to a variable litterly with out it adding the extra \





  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: another string question for C#

    If you don't need any escape characters in your path then you can create a verbatim string literal:
    Code:
    string path = @"C:\MyFolder\MyFile.txt";
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: another string question for C#

    how can i apply that to


    ofd_invoice.filename

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: another string question for C#

    You can't and you don't need to. The only reason to use it is to assign a literal string to a reference without having to escape any of the backslashes. There is no other use or need. If you're seeing escaped backslashes in the Watch window or somewhere like that it doesn't mean that your string contains double backslashes. That's just how string literals are displayed in C# so that's how the IDE displays them. If it just displayed single backslashes then how would it display escape characters?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: another string question for C#

    Quote Originally Posted by Crash893
    how can i apply that to


    ofd_invoice.filename
    You don't apply that to variables, just to values
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  6. #6

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: another string question for C#

    okay i assuemed that that was the problem becuase it was saying that it could not find the file that i spessify in my OFD

    i will have to take a closer look at see what else may be causeing it then


    Thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width