locked
How I can display Stream on the page? RRS feed

  • Question

  • User1959606010 posted

    I have a WCF method that I am calling, the method suppose to create a file but it create an exception. I try to find what is in the stream request that I am passing to this method. How I can alert or write this stream so I can find the content. That is my method:


     Stream UploadImage(Stream request)
            {
    
                Stream requestTest = request;
    
    
    
                HttpMultipartParser parser = new HttpMultipartParser(request, "data");
                string filePath = "";
                string passed = "";
                if (parser.Success)
                {
                  
    
                    // Save the file somewhere 
                    //File.WriteAllBytes(FILE_PATH + title + FILE_EXT, parser.FileContents);
    
                    // Save the file 
                    //SaveFile( mtp.Filename, mtp.ContentType, mtp.FileContents);
                    FileStream fileStream = null;
                    BinaryWriter writer = null;
    
    
                    try
                    {
    
                       
                        filePath = HttpContext.Current.Server.MapPath("Uploded\\test.jpg");  // BuildFilePath(strFileName, true);    
                        filePath = filePath.Replace("SSGTrnService\\", "");
                      
                        fileStream = new FileStream(filePath, FileMode.Create);
    



    it produces an error on this line :

    fileStream = new FileStream(filePath, FileMode.Create);

    that I try to understand why file can not created.



    Tuesday, May 14, 2013 6:45 PM

Answers

  • User-488622176 posted

    what exception is thrown?  Does the folder exist? Do you have write privileges on that folder? If you host the service under IIS, you'll not to write in a folder where the ASP.NET runtime account has access to. More on security settings under ASP.NET can be found here http://msdn.microsoft.com/en-us/library/ff647402.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 15, 2013 9:46 AM