locked
Is there any way to get FileUpload.PosetedFile.Inputstream property as string? RRS feed

  • Question

  • Hello,

    In my project i have used asp.net Fileupload control which works fine on my local machine. but when run that project on server i am not able to load the xls file. so i have used "Fileupload1.PostedFile.InputStream" property which returns as a Stream. By using this i can load excel file properly. but now i have to use as "string" instead of "stream" for further implementation. so how i can use "Fileupload1.PostedFile.InputStream" which returns Stream, and i can convert it into string and pass it to load excel file to run it properly on server also? can any one please help me?



    • Edited by Shinde K Wednesday, July 23, 2014 8:37 AM
    • Moved by Fred Bao Wednesday, July 30, 2014 9:45 AM
    Wednesday, July 23, 2014 6:26 AM

Answers

  • This forum is to discuss problems of C# development. Your question is not related to the topic of this forum.

    You'll need to post it in the dedicated ASP.Net Forum http://forums.asp.net for more efficient responses, where you can contact ASP.NET experts. Thanks for understanding.

    • Proposed as answer by Just Karl Monday, August 25, 2014 2:59 PM
    • Marked as answer by Just Karl Monday, September 22, 2014 9:20 PM
    Wednesday, July 30, 2014 9:30 AM

All replies

  • You can convert it like this:

    public string StreamToString(Stream stream)
    {
        using (var reader = new StreamReader(stream))
        {
            return reader.ReadToEnd();
        }
    }

    Wednesday, July 23, 2014 6:36 AM
  • This forum is to discuss problems of C# development. Your question is not related to the topic of this forum.

    You'll need to post it in the dedicated ASP.Net Forum http://forums.asp.net for more efficient responses, where you can contact ASP.NET experts. Thanks for understanding.

    • Proposed as answer by Just Karl Monday, August 25, 2014 2:59 PM
    • Marked as answer by Just Karl Monday, September 22, 2014 9:20 PM
    Wednesday, July 30, 2014 9:30 AM