Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Validating a date in a DateTimePicker Pin
hooray12-Apr-05 10:56
hooray12-Apr-05 10:56 
GeneralRe: Validating a date in a DateTimePicker Pin
drey113-Apr-05 6:03
drey113-Apr-05 6:03 
GeneralRe: Validating a date in a DateTimePicker Pin
drey113-Apr-05 6:41
drey113-Apr-05 6:41 
GeneralAutoscrolling textbox Pin
zagzagzag12-Apr-05 9:31
zagzagzag12-Apr-05 9:31 
GeneralRe: Autoscrolling textbox Pin
Darryl Borden12-Apr-05 11:00
Darryl Borden12-Apr-05 11:00 
GeneralRe: Autoscrolling textbox Pin
zagzagzag12-Apr-05 22:04
zagzagzag12-Apr-05 22:04 
Generalodbc stuff Pin
jobrown5vt12-Apr-05 8:43
jobrown5vt12-Apr-05 8:43 
Generalreplace text in a byte[] Pin
Ian Bowler12-Apr-05 7:30
Ian Bowler12-Apr-05 7:30 
Hello,

Here's what I'd like to do:

I have a byte[]. This could contain anything. I want to search it and replace every instance of "OldText" with "NewText". I'm actually trying to expand a token. So if I find the token, I want to replace it with the expanded value. Here's what I'm trying to do (pseudo-code)

------------------------------------------------------------------------

string Token = "%SomeToken%";
string Value = "ExpandedToken";

byte[] Data = GetRegBinary(); // Data contains some REG_BINARY data

System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();

// Convert the OldText to Base64String
byte[] buf1 = enc.GetBytes(Token);
string OldText = Convert.ToBase64String(buf1);

// Convert the NewText to Base64String
byte[] buf2 = enc.GetBytes(Value);
string NewText = Convert.ToBase64String(buf2);

// Convert the target data to Base64String
string TargetData = Convert.ToBase64String(Data);

// Now replace the OldData with the NewData in the TargetData
TargetData = TargetData.Replace(OldData, NewData);

// Convert the TargetData back to Byte[]
Data = Convert.FromBase64String(TargetData);

------------------------------------------------------------------------

I was hoping I could use some built-in encoding so I wouldn't have to write my own. This seems like a good logical approach but it's not working (I don't know why) and I'm getting the feeling that I'm using the wrong tool for the job...

Any ideas?

Thanks!

-Ian

GeneralRe: replace text in a byte[] Pin
Nick Parker12-Apr-05 9:39
protectorNick Parker12-Apr-05 9:39 
GeneralRe: replace text in a byte[] Pin
Ian Bowler12-Apr-05 9:47
Ian Bowler12-Apr-05 9:47 
GeneralLogin to Yahoo network Pin
ldself12-Apr-05 7:26
ldself12-Apr-05 7:26 
Generalformating datagrid Pin
la vie12-Apr-05 5:57
la vie12-Apr-05 5:57 
GeneralRe: formating datagrid Pin
MoustafaS12-Apr-05 14:17
MoustafaS12-Apr-05 14:17 
GeneralC# for Pocket PC Pin
Vitor Hugo Barros12-Apr-05 5:57
Vitor Hugo Barros12-Apr-05 5:57 
GeneralC# RegistryKey and GetType Pin
Brigg Thorp12-Apr-05 5:38
Brigg Thorp12-Apr-05 5:38 
GeneralRe: C# RegistryKey and GetType Pin
Ian Bowler12-Apr-05 7:36
Ian Bowler12-Apr-05 7:36 
GeneralRe: C# RegistryKey and GetType Pin
Brigg Thorp12-Apr-05 9:21
Brigg Thorp12-Apr-05 9:21 
GeneralRe: C# RegistryKey and GetType Pin
Dave Kreskowiak12-Apr-05 7:52
mveDave Kreskowiak12-Apr-05 7:52 
GeneralRe: C# RegistryKey and GetType Pin
Brigg Thorp12-Apr-05 9:25
Brigg Thorp12-Apr-05 9:25 
QuestionCan i stop people from deleting a file? Pin
Anthony Mushrow12-Apr-05 5:37
professionalAnthony Mushrow12-Apr-05 5:37 
AnswerRe: Can i stop people from deleting a file? Pin
Dave Kreskowiak12-Apr-05 7:21
mveDave Kreskowiak12-Apr-05 7:21 
AnswerRe: Can i stop people from deleting a file? Pin
afinnell15-Apr-05 13:55
afinnell15-Apr-05 13:55 
GeneralC# COM Interop Pin
s2111979212-Apr-05 4:30
s2111979212-Apr-05 4:30 
GeneralMake an instance of a child form from a class file. Pin
Mike Jeferson12-Apr-05 4:23
Mike Jeferson12-Apr-05 4:23 
GeneralC# Connection to Northwind via SQL - HELP Pin
Jethro6312-Apr-05 4:08
Jethro6312-Apr-05 4:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.