473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

issue regarding encoding

hello all,

I am using vb.net to read a image file and then tryied to convert it to a
string using the following code

Dim fs As FileStream = New FileStream(filename,
FileMode.OpenOrCreate, FileAccess.Read)
Dim rawData() As Byte = New Byte(fs.Length) {}
fs.Read(rawData, 0, System.Convert.ToInt32(fs.Length))
fs.Close()

dim filedata as string
filedata=System.Text.ASCIIEncoding.ASCII.GetString (rawData)

Upto this point it get converted into string

Now I am passing this string to some web service where i want to get the
image back from this string

I write my code like this

Dim bw As BinaryWriter
Dim outbuff() As Byte
outbuff =
System.Text.ASCIIEncoding.ASCII.GetBytes(filedata )
fs = New FileStream("C:\" & nodeattrib.Value,
FileMode.Create, FileAccess.Write)
fs.Write(outbuff, 0, outbuff.Length)

File is created in the path specified but, i cannot open it.

Can Anyone help me out in this case.

It is very urgent

Thanks in advance
--
Sunil Pandita
Software Engineer
(OTS Solutions Pvt. Ltd. )

Nov 23 '05 #1
2 920

when you want to sent Binary files like that over the wire , you would
better encode base 64 the binarry , send it over and decode base 64 the
string to binarry

this worked perfectly in my projects

hth

Michel Posseth [MCP]

"sunil" <su***@discussions.microsoft.com> schreef in bericht
news:06**********************************@microsof t.com...
hello all,

I am using vb.net to read a image file and then tryied to convert it to a
string using the following code

Dim fs As FileStream = New FileStream(filename,
FileMode.OpenOrCreate, FileAccess.Read)
Dim rawData() As Byte = New Byte(fs.Length) {}
fs.Read(rawData, 0, System.Convert.ToInt32(fs.Length))
fs.Close()

dim filedata as string
filedata=System.Text.ASCIIEncoding.ASCII.GetString (rawData)

Upto this point it get converted into string

Now I am passing this string to some web service where i want to get the
image back from this string

I write my code like this

Dim bw As BinaryWriter
Dim outbuff() As Byte
outbuff =
System.Text.ASCIIEncoding.ASCII.GetBytes(filedata )
fs = New FileStream("C:\" & nodeattrib.Value,
FileMode.Create, FileAccess.Write)
fs.Write(outbuff, 0, outbuff.Length)

File is created in the path specified but, i cannot open it.

Can Anyone help me out in this case.

It is very urgent

Thanks in advance
--
Sunil Pandita
Software Engineer
(OTS Solutions Pvt. Ltd. )

Nov 23 '05 #2
"m.posseth" <po*****@planet.nl> schrieb:
when you want to sent Binary files like that over the wire , you would
better encode base 64 the binarry , send it over and decode base 64 the
string to binarry


ACK. You can use 'Convert.ToBase64*' and 'Convert.FromBase64*' for this
purpose.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: George Hester | last post by:
Please take a look at this google artcle: http://groups.google.com/groups?hl=en&lr=&frame=right&th=55d6f4b50f5f9382&seekm=411f370d%241%40olaf.komtel.net#link9 The op was having trouble with...
4
by: Gauthier | last post by:
Hi, I've a simple issue with the use of extension objects. I'm trying to call a text formating method from an object that I add to my arguments collection, this method take an input string and...
2
by: MWells | last post by:
I've encountered an interesting issue regarding Url encoding that I'm hopeful someone can shed some light on. I have some vanity Url's that have to contain filename content, using the file...
3
by: Ron Clabo | last post by:
I have a URL Decoding issue. The text that needs to be decoded is: "123+H%F6gbergsgatan+st" The decoded version should equate to: "123 Högbergsgatan st"
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
17
by: 57R4N63R | last post by:
I'm currently building a website for one of the client. There has been few errors here and there, but just recently the problem is getting worse. Basically the symptoms is that when the user try...
1
by: Robert | last post by:
I have a server where the main web application (root) is now migrated to 2.0. It's web.config has a line where it adds the system.data.oracleclient in the configuration and assembiles section. ...
3
by: c676228 | last post by:
Hi all, If I developed a phone user control which has requiredfieldvalidator, regularexpressionvalidator etc. The quesiton is if on a web form which have three phone fields and only any one of...
11
by: prats | last post by:
I want to write a GUI application in PYTHON using QT. This application is supposed to take in Japanese characters. I am using PyQt as the wrapper for using QT from python. I am able to take input...
5
by: Seb | last post by:
Hi, We have a page in VB.NET redirecting to an external site. Example: http://mysite.com/redirect.aspx?url=http//externalsite.com/their-page.asp The target page on the external site...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.