Results 1 to 13 of 13

Thread: split function

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    split function

    i wanna split a string with the split functions by spliting by the "large" keyword...i tryed making

    myString.Split("large");

    and it didnt work..it says it needs an char array... i made one but he keeps only loooking for the 1st letter of the split string(in this case l)..what am i doin wrong?
    \m/\m/

  2. #2

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    tyy
    \m/\m/

  4. #4

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i've asked myself what would mean the Regex.Split method when looking by info on msdn but never clicked in the link to that... lol

    its workin like a sharm =)
    \m/\m/

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    damn when trying in run-time it returned a System.IO.StreamReader...
    \m/\m/

  6. #6

  7. #7

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    nvm the problem was the string i was trying to split was saying that
    \m/\m/

  8. #8

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    PHP Code:
                string fileName = @"C:\Documents and Settings\JBRANCO\Desktop\dev.txt";
                
    string lol System.IO.File.OpenText(fileName).ToString();
                
    MessageBox.Show(lol); 
    this is returning System.io.streamreader...what am i doin wrong? invalid cast maybe..?
    \m/\m/

  9. #9
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Your going to want to do something like this:
    Code:
    string input = null;
    
    // Open the file
    try
    {
    	System.IO.StreamReader re = System.IO.File.OpenText("YourFile");
    
                    // This will put the file as a string variable for you.
    	input = re.ReadToEnd();
    
    	// Close the streamreader.
    	re.Close();
    }
    catch
    {
    	MessageBox.Show("File Problem");
    }

  10. #10

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    the problem is the same...it isnt as string format
    \m/\m/

  11. #11
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Did you do what I did in my post? If the file your opening is a text file, then use what I posted. When you use the OpenText method, it returns a streamreader. You then need to tell the streamreader to give you text. That is what this line does:
    input = re.ReadToEnd();
    input is a string variable.

  12. #12
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    //Check your file name and path, it looks incorrect to me
    string fileName = @"C:Documents and Settings\JBRANCODesktopdev.txt";
    string text;
    StreamReader re = System.IO.File.OpenText(fileName);
    text = re.ReadToEnd();
    re.Close();
    MessageBox.Show(text);

  13. #13

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    k tks worked
    \m/\m/

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