Results 1 to 7 of 7

Thread: [RESOLVED] problem with string

  1. #1

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

    Resolved [RESOLVED] problem with string

    i am trying to declare a string in C#

    string
    writePath,
    billMonth,
    startPath = '\\filervoca\groups\edit\public' ;

    for startPath i get an error for either ' or " im not sure how to intalize thie value to this network folder.


    thanks

    crash

  2. #2
    Member
    Join Date
    Sep 2006
    Posts
    39

    Re: problem with string

    declare your string as

    Code:
            public string startPath = "\\filervoca\\groups\\edit\\public" ;
    
    or
    
    
            public string startPath2 = @"\\filervoca\groups\edit\public";
    I beleive the single \ is an escape clause and by either putting a double \\ or by placing the @ before the path it turns it into a literal(sp) path.

    I'm sure others will correct my example but the code working in my test.

    Al

  3. #3
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: problem with string

    Code:
    public string startPath = "\\\\filervoca\\groups\\edit\\public" ;
    4 \s to get \\
    Show Appreciation. Rate Posts.

  4. #4
    Member
    Join Date
    Sep 2006
    Posts
    39

    Re: problem with string

    Quote Originally Posted by Harsh Gupta
    Code:
    public string startPath = "\\\\filervoca\\groups\\edit\\public" ;
    4 \s to get \\
    Good shout Harsh Gupta!


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

    Re: problem with string

    I remember when they told me to do things the easy way
    Code:
    string startPath = @"\\filervoca\groups\edit\public";
    "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: problem with string

    Works thanks

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

    Re: [RESOLVED] problem with string

    If you have only escape backslashes in a string then don't use the verbatim operator, e.g.
    Code:
    myTextBox.Text = "line 1\nline 2";
    If you have only literal backslashes in a string then do use the verbatim operator, e.g.
    Code:
    myTextBox.Text = @"The path is C:\Files\MyFile.txt";
    If you have both escape and literal backslashes then don't use the verbatim operator and do escape your literal backslashes, e.g.
    Code:
    myTextBox.Text = "The path is as follows:\n\"C:\\Files\\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

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