NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 7 8 9 10 11 … 93 Next »
Replace characters in strings

 
  • 0 Vote(s) - 0 Average
Replace characters in strings
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,583
Threads: 384
Joined: Dec 2004
#1
2013-07-06, 01:43 AM
Initially I thought I had this working but it appears it doesn't. Not sure what I'm missing here. Trying to remove characters from channel names which are invalid for file names...
Code:
char[] InvalidPathChars = System.IO.Path.GetInvalidPathChars();
...
foreach (String chanName in chanNamesList)
{
    StringBuilder sb = new StringBuilder(chanName);
    foreach (char item in InvalidPathChars)
        sb.Replace(item.ToString(), "");
    String chanLogoFilename = sb.ToString();

    Log.WriteLine("GenerateChannelLogosFile() - Looking for logo: " + chanLogoFilename);
    // Append .jpg, .png and .gif in turn to try to find channel logo image file
    ...
}
However when I look at the logging for the channel 5*, I see...
Code:
GenerateChannelLogosFile() - Looking for logo: 5*
...so the asterisk obviously isn't being removed and my 5.png file obviously isn't being found. I just can't see what isn't working - anyone any ideas?

Cheers,
Brian
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#2
2013-07-06, 02:14 AM
If it was java it'd need to be something = sb.replace as strings are immutable - you can only make new ones, not change existing ones. Might be different with a StringBuilder tho.

On my phone, hence shortish reply.

Iain
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,583
Threads: 384
Joined: Dec 2004
#3
2013-07-06, 02:28 AM
imilne Wrote:If it was java it'd need to be something = sb.replace as strings are immutable - you can only make new ones, not change existing ones. Might be different with a StringBuilder tho.
As it turns out, doing it in Java was a bit of a pig but I actually got it working - it was then I realised it was looking for 5.png but the nDroid Server wasn't packaging it.

As ever, 10 minutes after posting a dev question I've worked it out (despite staring at it for 30 minutes before posting). Thinking about it * is, in fact, a valid path character, e.g., dir c:\*.* so the char[] returned by System.IO.Path.GetInvalidPathChars() doesn't include it. What I needed was...

Code:
System.IO.Path.GetInvalidFileNameChars()
...instead. Doh!!!

Cheers,
Brian
ACTCMS
Offline

Posting Freak

UK
Posts: 2,730
Threads: 101
Joined: Jun 2007
#4
2013-07-06, 02:36 AM
bgowland Wrote:As ever, 10 minutes after posting a dev question I've worked it out (despite staring at it for 30 minutes before posting).
We used to call that 'Structured Walkthrough' - it seldom fails... Smile

Alex
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,583
Threads: 384
Joined: Dec 2004
#5
2013-07-06, 02:56 AM
ACTCMS Wrote:We used to call that 'Structured Walkthrough' - it seldom fails... Smile

Alex
Yes it's pretty effective....I just wish I'd posted the question 30 minutes earlier rather than doing the "staring at my code" thing. Big Grin

Cheers,
Brian
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,767
Threads: 954
Joined: May 2006
#6
2013-07-06, 03:42 AM
http://forums.nextpvr.com/showthread.php...post383840

Martin
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Scheduled_Recordings - Filename field limited to 50 characters? JavaWiz 6 4,395 2015-10-28, 10:46 PM
Last Post: JavaWiz
  How to convert special characters to use for a URL bgowland 2 1,494 2012-01-21, 05:35 PM
Last Post: bgowland
  Swedish Characters in VB zehd 1 1,339 2006-11-15, 07:29 PM
Last Post: stefan
  splitting a long string into multiple strings reven 45 10,025 2005-03-12, 02:18 PM
Last Post: reven

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode