Click here to Skip to main content
15,916,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I am using ActiveX Object to read text files of local drives. But i am not able read read an image (bmp or Gif) with ActiveX Object. i want read it as a byte array and pass the same to server. Can anybody tell me how can i read local system's image files and pass it to server side code as a byte array

Note :- my code for reading text file is as follows
C#
var ForReading = 1, ForWriting = 2, ForAppending = 8;
var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;

var fso = new ActiveXObject(Scripting.FileSystemObject);
// Open a text stream for input.
var fileObj = fso.GetFile("d:\\abc.txt");
ts = fileObj.OpenAsTextStream(ForReading, TristateUseDefault);

var cont = ts.ReadAll();


Thanks & Regards
Shiyas
Posted
Updated 21-Jan-11 2:49am
v2
Comments
Indivara 21-Jan-11 8:50am    
minor edit, formatting & spelling
Manfred Rudolf Bihy 21-Jan-11 9:38am    
Shiyas, you were given answers to your second question here on CP. You must have found at least one of them useful as you are now asking how to do it via ActiveX FileSystemObject as was the advice given to you. How can it be then that you didn't even vote on the good advice that was poured on you.

If you receive answers or advice that helps you please be so kind to vote on it.

Thanks for your attention!
Sergey Alexandrovich Kryukov 21-Jan-11 12:34pm    
Manfred, I think it's not so easy. OP started with scripting ActiveX

It's here:
http://msdn.microsoft.com/en-us/library/6kxy1a51(v=vs.85).aspx

The problem is working with arbitrary files. This Active is oriented to text files. The Microsoft documentation on the topic is not so good as Microsoft's usual, in particular, function descriptions lack return value. Somewhere, I saw a mention that binary is not supported -- yet, but...

I think OP still could you some help.

Anyway, Shiyas... you're the most interesting party. Do some search, don't wait.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900