File Return type with Bytes [Resolved]

Posted by Manicse under C# on 11/25/2016 | Points: 10 | Views : 309 | Status : [Member] | Replies : 1
Hi,

I want to upload file to specific location using asp.net web service.
I have tried to write the code like below.


byte[] file = FileUpload1.FileBytes;


with passing web service. Web service works fine as of now .But client can be windows service may not web application.
File path can be sent to service. From file path,I want to convert to byte array.

So I used the below code

 byte[] array = File.ReadAllBytes("C:\\Users\\mani\\Desktop\\sample123.txt");


But it is not working.
Array always contain zero{byte[0]}. Not sure what is the issue here.
Kindly let me know if somebody have an idea.

Mani.R


Responses

Posted by: Rajnilari2015 on: 12/5/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Try

var filePath = "C:\Users\mani\Desktop\sample123.txt";
var array = File.ReadAllBytes(@filePath);


--
Thanks & Regards,
RNA Team

Manicse, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response