Solved

How to Encode URL in Base64 in C# windows application?

Posted on 2006-11-13
10
3,578 Views
Last Modified: 2008-01-09
Hi,

I want to encode an URL in to Base64 in c# windows application.
Please help me.
0
Comment
Question by:vikasbapat
  • 5
  • 3
  • 2
10 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17929074
Get the URL string as byte[] and then do Convert.ToBase64String(byte[]);
0
 

Author Comment

by:vikasbapat
ID: 17929308
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17929363
This ought to work:

using System.Text;

byte[] urlBytes = Encoding.ASCII.GetBytes(url);
string urlB64 = Convert.ToBase64String(urlBytes);

If you want the URL treated as, for example, Unicode, you would change the encoding like so:

byte[] urlBytes = Encoding.Unicode.GetBytes(url);
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 16

Accepted Solution

by:
muzzy2003 earned 500 total points
ID: 17929364
(or something like that - typed outside of VS)
0
 

Author Comment

by:vikasbapat
ID: 17929416
It is working fine.

Thanks for quick responce.
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17929433
Thanks, I tell you how to encode to base64 and you award points for converting a string to bytes.
You could have at least split the points there.
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17929730
Yes, agreed. And a B?
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17930036
(BTW ozymandias, hadn't intended to steal this one, just saw it in passing. Assumed you'd already basically won the points ...)
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17930163
Don't worry about it, these things happen.
I nearly came back and added the bit about converting a string to bytes but thought that was kinda overkill.
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17930184
:)
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question