By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,707 Members | 1,636 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,707 IT Pros & Developers. It's quick & easy.

How to transfer file in .resx and transfer to Strem

P: n/a
ad
I wnat to load a file in an .resx file and transfer the file to a stream.
How can I do?
May 10 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
well resx is itself a file so if you see question its like uploading file and
another file .... but anyways you can open file to upload and read it using
classes in System.IO namespace and then can convert those bytes into
BASE64String using system.text namespace classes and save this string to resx
file. At the time of retrieving you can then decode this Base64String.
"ad" wrote:
I wnat to load a file in an .resx file and transfer the file to a stream.
How can I do?

May 10 '06 #2

P: n/a
well resx is itself a file so if you see question its like uploading file in
another file .... but anyways you can open file to upload and read it using
classes in System.IO namespace and then can convert those bytes into
BASE64String using system.text namespace classes and save this string to resx
file. At the time of retrieving you can then decode this Base64String.
"ad" wrote:
I wnat to load a file in an .resx file and transfer the file to a stream.
How can I do?

May 10 '06 #3

P: n/a
ad
Thanks,
I mean for example: I have a Excel file stored in a Resource File.
How can I retrive the Excel file?

"Altaf Al-Amin Najwani" <Al****************@discussions.microsoft.com> 级糶秎ン穝籇:0A********************************* *@microsoft.com...
well resx is itself a file so if you see question its like uploading file
in
another file .... but anyways you can open file to upload and read it
using
classes in System.IO namespace and then can convert those bytes into
BASE64String using system.text namespace classes and save this string to
resx
file. At the time of retrieving you can then decode this Base64String.
"ad" wrote:
I wnat to load a file in an .resx file and transfer the file to a stream.
How can I do?

May 10 '06 #4

P: n/a
ok , I can't give u exact code here as i dont have VS.Net with me right now
... But lets start, You can use system.IO namespace
Create object of FileStream Providing name of file and filemode which is open
Then Read file using objFileStream.Read(byteArray,offset, length)
After Read you will get whole file in byteArray in form of bytes.
Now you can use Convert.ToBase64String(byteArray) to convert this file as
Base64String and store this string in resx file. You can also store file name
in resx file too. While Retrieving Read Base64String from resource file ,
again convert it back to bytearray, Create FileStream and save this
byteStream as filename stored in resx file.

"ad" wrote:
Thanks,
I mean for example: I have a Excel file stored in a Resource File.
How can I retrive the Excel file?

"Altaf Al-Amin Najwani" <Al****************@discussions.microsoft.com> 录露录g漏贸露l楼贸路s禄D:0A*********************** ***********@microsoft.com...
well resx is itself a file so if you see question its like uploading file
in
another file .... but anyways you can open file to upload and read it
using
classes in System.IO namespace and then can convert those bytes into
BASE64String using system.text namespace classes and save this string to
resx
file. At the time of retrieving you can then decode this Base64String.
"ad" wrote:
I wnat to load a file in an .resx file and transfer the file to a stream.
How can I do?


May 10 '06 #5

P: n/a
ad
Thanks,
Maybe I must express my problem more:

I have store a Excel file (name my.xls) in the Resource file of a class
library project with the IDE of VS2005.
Now I want to retrive my.xls in code:
------------------------------------------------------------------------
ResourceManager a = new ResourceManager("WillNs.MyResource",
Assembly.GetExecutingAssembly());

Byte[] byteExcel = a.GetObject("my", CultureInfo.CurrentCulture);
-------------------------------------------------------------------------

Now how can I transfer the Byte[] to Stream?

"Altaf Al-Amin Najwani" <Al****************@discussions.microsoft.com> 级糶秎ン穝籇:89********************************* *@microsoft.com...
ok , I can't give u exact code here as i dont have VS.Net with me right
now
.. But lets start, You can use system.IO namespace
Create object of FileStream Providing name of file and filemode which is
open
Then Read file using objFileStream.Read(byteArray,offset, length)
After Read you will get whole file in byteArray in form of bytes.
Now you can use Convert.ToBase64String(byteArray) to convert this file as
Base64String and store this string in resx file. You can also store file
name
in resx file too. While Retrieving Read Base64String from resource file ,
again convert it back to bytearray, Create FileStream and save this
byteStream as filename stored in resx file.

"ad" wrote:
Thanks,
I mean for example: I have a Excel file stored in a Resource File.
How can I retrive the Excel file?

"Altaf Al-Amin Najwani" <Al****************@discussions.microsoft.com>
???gco?los?D:0A******************************* ***@microsoft.com...
> well resx is itself a file so if you see question its like uploading
> file
> in
> another file .... but anyways you can open file to upload and read it
> using
> classes in System.IO namespace and then can convert those bytes into
> BASE64String using system.text namespace classes and save this string
> to
> resx
> file. At the time of retrieving you can then decode this Base64String.
>
>
> "ad" wrote:
>
>> I wnat to load a file in an .resx file and transfer the file to a
>> stream.
>> How can I do?
>>
>>
>>


May 10 '06 #6

P: n/a
MemoryStream m = new MemoryStream(byteExcel)

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:uF**************@TK2MSFTNGP02.phx.gbl...
Thanks,
Maybe I must express my problem more:

I have store a Excel file (name my.xls) in the Resource file of a class
library project with the IDE of VS2005.
Now I want to retrive my.xls in code:
------------------------------------------------------------------------
ResourceManager a = new ResourceManager("WillNs.MyResource",
Assembly.GetExecutingAssembly());

Byte[] byteExcel = a.GetObject("my", CultureInfo.CurrentCulture);
-------------------------------------------------------------------------

Now how can I transfer the Byte[] to Stream?

"Altaf Al-Amin Najwani" <Al****************@discussions.microsoft.com>
级糶秎ン穝籇:89********************************* *@microsoft.com...
ok , I can't give u exact code here as i dont have VS.Net with me right
now
.. But lets start, You can use system.IO namespace
Create object of FileStream Providing name of file and filemode which is
open
Then Read file using objFileStream.Read(byteArray,offset, length)
After Read you will get whole file in byteArray in form of bytes.
Now you can use Convert.ToBase64String(byteArray) to convert this file as
Base64String and store this string in resx file. You can also store file
name
in resx file too. While Retrieving Read Base64String from resource file ,
again convert it back to bytearray, Create FileStream and save this
byteStream as filename stored in resx file.

"ad" wrote:
Thanks,
I mean for example: I have a Excel file stored in a Resource File.
How can I retrive the Excel file?

"Altaf Al-Amin Najwani" <Al****************@discussions.microsoft.com>
???gco?los?D:0A******************************* ***@microsoft.com...
> well resx is itself a file so if you see question its like uploading
> file
> in
> another file .... but anyways you can open file to upload and read it
> using
> classes in System.IO namespace and then can convert those bytes into
> BASE64String using system.text namespace classes and save this string
> to
> resx
> file. At the time of retrieving you can then decode this Base64String.
>
>
> "ad" wrote:
>
>> I wnat to load a file in an .resx file and transfer the file to a
>> stream.
>> How can I do?
>>
>>
>>


May 10 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.