Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在c中上载时,从图像中删除Exif数据的最佳方法是什么#_C#_Asp.net_File Upload_Exif - Fatal编程技术网

C# 在c中上载时,从图像中删除Exif数据的最佳方法是什么#

C# 在c中上载时,从图像中删除Exif数据的最佳方法是什么#,c#,asp.net,file-upload,exif,C#,Asp.net,File Upload,Exif,在c#中上载时,从图像中删除Exif数据的最佳方法是什么? 我尝试了以下给出的解决方案: 但我面临的问题是,在保存来自上述解决方案的输出流后,图像不可读。 它从文件中删除Exif信息。但我以后无法查看图像 有人能帮我吗 下面是我的代码: protected void SaveFile() { try { JpegPatcher _jpegPatcher = new JpegPatcher(); Sy

在c#中上载时,从图像中删除Exif数据的最佳方法是什么? 我尝试了以下给出的解决方案:

但我面临的问题是,在保存来自上述解决方案的输出流后,图像不可读。 它从文件中删除Exif信息。但我以后无法查看图像

有人能帮我吗

下面是我的代码:

    protected void SaveFile()
    {
        try
        {
            JpegPatcher _jpegPatcher = new JpegPatcher();
            System.IO.Stream stream = new System.IO.MemoryStream();
            //Get stream data of uploaded file
            Stream checkStream = fileUpload.PostedFile.InputStream;
            //Pass the stream to remove Exif info
            Stream outStream1 = _jpegPatcher.PatchAwayExif(checkStream, stream);

            //Save the file
            string Fpath = Path.Combine(path, fileUpload.FileName);
            using (FileStream outputFileStream = new FileStream(Fpath, FileMode.Create, FileAccess.Write))
            {
                stream.Position = 0;
                stream.CopyTo(outputFileStream);
                stream.Flush();
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

这是否有帮助,并简化。请记住,在开始读取时,确保输入流上的位置为0

        JpegPatcher _jpegPatcher = new JpegPatcher();
        //Get stream data of uploaded file
        Stream checkStream = fileUpload.PostedFile.InputStream;
        checkStream.Position = 0; // Reset position
        //Pass the stream to remove Exif info
        //Save the file
        string Fpath = Path.Combine(path, fileUpload.FileName);
        using (FileStream outputFileStream = new FileStream(Fpath, FileMode.Create, FileAccess.Write))
        {
            _jpegPatcher.PatchAwayExif(checkStream, outputFileStream);
        }