473,407 Members | 2,676 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,407 software developers and data experts.

Convert String in file

Is it possible to convert a string in a file. The problem is this:
I have an object string that is a file xml and I want to pass to Deserialize
function, but Deserialize function expect an object of FileStream type and
the mode access.
There is a function Convert.ChangeType(object value, Type conversionType),
but I cant write for example:
Convert.ChangeType(mystring, FileStream);
CAN YOU HELP ME????? thanks
Mar 23 '06 #1
3 7949
Hi,

Are you sure that you need a FileStream instnace and not a Stream one?

If you can use a Stream instance what you can do is decorate the string as a
MemoryStream and pass it to the Deserialize method
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ursula" <Ur****@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
Is it possible to convert a string in a file. The problem is this:
I have an object string that is a file xml and I want to pass to
Deserialize
function, but Deserialize function expect an object of FileStream type
and
the mode access.
There is a function Convert.ChangeType(object value, Type conversionType),
but I cant write for example:
Convert.ChangeType(mystring, FileStream);
CAN YOU HELP ME????? thanks

Mar 23 '06 #2
Is a possible solution!But how I can do this?
How I can convert string in a Stream type?

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Are you sure that you need a FileStream instnace and not a Stream one?

If you can use a Stream instance what you can do is decorate the string as a
MemoryStream and pass it to the Deserialize method
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ursula" <Ur****@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
Is it possible to convert a string in a file. The problem is this:
I have an object string that is a file xml and I want to pass to
Deserialize
function, but Deserialize function expect an object of FileStream type
and
the mode access.
There is a function Convert.ChangeType(object value, Type conversionType),
but I cant write for example:
Convert.ChangeType(mystring, FileStream);
CAN YOU HELP ME????? thanks


Mar 23 '06 #3
Hi,
"Ursula" <Ur****@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
Is a possible solution!But how I can do this?
How I can convert string in a Stream type?


You do not convert it, you just initialize a new MemoryStream with the
content of the string

Take a look at the constructor.

From memory I think this is the way to go:

new MemoryStream( Encoding.ASCII.GetBytes( your_string) );

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Mar 23 '06 #4

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

Similar topics

1
by: mevar81 | last post by:
Hello to everybody.I have a problem.I used a TypeDescriptor to retrieve a TypeConverter to convert an Image to a string.The problem is that it converts the image to the string...
2
by: Mel WEaver | last post by:
Hello, I have the following delphi structure for a binary file. I'm looking for idea how to read this file. Mel type TMenuDataStruct = packed record exename : string;
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
12
by: Brian Henry | last post by:
first question... I have a flat file which unfortinuatly has columns seperated by nulls instead of spaces (a higher up company created it this way for us) is there anyway to do a readline with this...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
3
by: GM | last post by:
Dear all, Could you all give me some guide on how to convert my big5 string to unicode using python? I already knew that I might use cjkcodecs or python 2.4 but I still don't have idea on what...
7
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006...
5
by: Dave Bootsma | last post by:
I have an application where I want to redraw a polygon from points I retrieve from a file. The file is read with streamreader line by line each line contains the points for each polygon. Below is...
19
by: est | last post by:
From python manual str( ) Return a string containing a nicely printable representation of an object. For strings, this returns the string itself. The difference with repr(object) is that...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.