Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#3.0 WCF
Hi All,
I need to send a file using a stream using WCF services. I got an error when trying to get the length of the stream.
At the service when I pass the stream I found that the stream properties like stream length,etc are not allowing.
I got following message "Specified method is not supported, SystemNotSupportedException". The stream I passed to the service is a FileStream casted to row Stream since I need to read a file and WCF only accepts row Streams.
Can someone find a solution for this?
Posted 12-Aug-10 23:19pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

what I would do is read the content of the file in to an array and send that to the client. in that case you would need to include the file type probably, better yet you can create a wrapper for it
       class Filewrapper
           public byte[] FileContent { get; private set; }
           public string FileName { get; private set; }
           public Filewrapper()
           { }
           /// <summary>
           /// </summary>
           /// <param name="content"></param>
           /// <param name="name">only the file name not the full path</param>
           public Filewrapper(byte[] content, string name)
               FileContent = content;
               FileName = name;
then your service would return something like this
string strpath="file path";
Filewrapper fl = new Filewrapper(File.ReadAllBytes(strpath),Path.GetFileName(strpath));
hope this helps
thanushkag at 16-Aug-10 3:29am
Hi Thanks for answering, I tried to send as a byte array, but the problem is it's not working when the file size is large. I need to send large files.
Vinayaka Krishna Shenoy at 16-Aug-10 4:29am
If it says file is large,then you might have to tune the entries for maxreceivedmessage size, max arrayay langth and Buffer size.
Try to increase those values.
I hope this helps!.
samqty at 16-Aug-10 22:57pm
yap! there are a bunch of default setting for the channel in the config file. all you gotta do is increase those values and it should work for you. I have used WCF for a file server and had run into the same issue.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 7,442
1 OriginalGriff 5,996
2 Peter Leow 4,292
3 CHill60 2,858
4 Mika Wendelius 2,850

Advertise | Privacy | Mobile
Web01 | 2.8.150224.1 | Last Updated 13 Aug 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100