下载不带前缀C#

时间:2018-07-13 07:07:24

标签: c# image download

我要下载图像具有这样的链接:

  

数据:图像/ PNG; BASE64,iVBORw0KGgoAAAANSUhEUgAAAXYAAAAzCAYAAACDvCMOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABBmSURBVHherY5BisRADMTy / 0 / PngS1gsJusECHlouQ73fM933 / BL + hdcOu7d1zm5qpW2gdpm5Nu7ujcc9tdvAdwW / I7cUdjXtus8PULbQO7rlNzesdwW / I7eaO4DfkdnNH4z7tLLQO7b7tFlo33iG0t / sV519sP + w3tG7Ytb17blMzdQutw9StaXd3NO65zQ6 + I / gNub24o3HPbXaYuoXWwT23qXm9I / gNud3cEfyG3G7uaNynnYXWod233ULrxjuE9na / 4vyL7Yf9htYNu7Z3z21qpm6hdZi6Ne3ujsY9t9nBdwS / IbcXdzTuuc0OU7fQOrjnNjWvdwS / IbebO4LfkNvNHY37tLPQOrT7tlto3XiH0N7uV5x / sf2w39C6Ydf27rlNzdQttA5Tt6bd3dG45zY7 + I7gN + T24o7GPbfZYeoWWgf33Kbm9Y7gN + R2c0fwG3K7uaNxn3YWWod233YLrRvvENrb / YrzL7Yf9htaN + za3j23qZm6hdZh6ta0uzsa99xmB98R / IbcXtzRuOc2O0zdQuvgntvUvN4R / Ibcbu4IfkNuN3c07tPOQuvQ7ttuoXXjHUJ7u19x / sX2w35D64Zd27vnNjVTt9A6TN2adndH457b7OA7gt + Q24s7GvfcZoepW2gd3HObmtc7gt + Q280dwW / I7eaOxn3aWWgd2n3bLbRuvENob / crzr / YfthvaN2wa3v33KZm6hZah6lb0 + 7uaNxzmx18R / AbcntxR + OE2 + wwdQutg3tuU / N6R / Abcru5I / gNud3c0bhPOwutQ7tvu4XWjXcI7e1 + xfkX2w / 7Da0bdm3vntvUTN1C6zB1a9rdHY17brOD7wh + Q24v7mjcc5s dpm6hdXDPbWpe7wh + Q243dwS / IbebOxr3aWehdWj3bbfQuvEOob3drzj / Yvthv6F1w67t3XObmqlbaB2mbk27u6Nxz2128B3Bb8jtxR2Ne26zw9QttA7uuU3N6x3Bb8jt5o7gN + R2c0fjPu0stA7tvu0WWjfeIbS3 + xXnX2w / 7De0bti1vXtuUzN1C63D1K1pd3c07rnNDr4j + A25vbijcc9tdpi6hdbBPbepeb0j + A253dwR / Ibcbu5o3Kedhdah3bfdQuvGO4T2dr / I / Ivth / 2G1g27tnfPbWqmbqF1mLo17e6Oxj232cF3BL8htxd3NO65zQ5Tt9A6uOc2Na93BL8ht5s7gt + Q280djfu0s9A6tPu2W2jdeIfQ3u5XnH + X / bDf0Lph1 / buuU3N1C20DlO3pt3d0bjnNjv4juA35PbijsY9t9lh6hZaB / fcpub1juA35HZzR / Abcru5o3GfdhZah3bfdgutG + 8Q2tv9ivMvth / 2G1o37NrePbepmbqF1mHq1rS7Oxr33GYH3xH8htxe3NG45zY7TN1C6 + Ce29S83hH8htxu7gh + Q243dzTu085C69Du226hdeMdQnu7X3H + xfbDfkPrhl3bu + c2NVO30DpM3Zp2d0fjntvs4DuC35Dbizsa99xmh6lbaB3cc5ua1zuC35DbzR3Bb8jt5o7GfdpZaB3afdsttG68Q2hv9yvOv9h + 2G9o3bBre / fcpmbqFlqHqVvT7u5o3HObHXxH8Btye3FH457b7DB1C62De25T83pH8Btyu7kj + A253dzRuE87C61Du2 + 7hdaNdwjt7X7F + RfbD / sNrRt2be + e29RM3ULrMHVr2t0djXtus4PvCH5Dbi / uaNxzmx2mbqF1cM9tal7vCH5Dbjd3BL8ht5s7GvdpZ6F1aPdtt9C68Q6hvd2vOP9i + 2G / oXXDru3dc5uaqVtoHaZuTbu7o3HPbXbwHcFvyO3FHY17brPD1C20Du65Tc3rHcFvyO3 mjuA35HZzR + M + 7Sy0Du2 + 7RZaN94htLf7FedfbD / sN7Ru2LW9e25TM3ULrcPUrWl3dzTuuc0OviP4Dbm9uKNxz212mLqF1sE9t6l5vSP4Dbnd3BH8htxu7mjcp52F1qHdt91C68Y7hPZ2v + L8i + 2H / YbWDbu2d89taqZuoXWYujXt7o7GPbfZwXcEvyG3F3c07rnNDlO30Dq45zY1r3cEvyG3mzuC35DbzR2N + 7Sz0Dq0 + 7ZbaN14h9De7lecf7H9sN / QumHX9u65Tc3ULbQOU7em3d3RuOc2O / iO4Dfk9uKOxj232WHqFloH99ym5vWO4DfkdnNH8Btyu7mjcZ92FlqHdt92C60b7xDa2 / 2K8y + 2H / YbWjfs2t49t6mZuoXWYerWtLs7GvfcZgffEfyG3F7c0bjnNjtM3ULr4J7b1LzeEfyG3G7uCH5Dbjd3NO7TzkLr0O7bbqF14x1Ce7tfcf7F9sN + Q + uGXdu75zY1U7fQOkzdmnZ3R + OE2 + zgO4LfkNuLOxr33GaHqVtoHdxzm5rXO4LfkNvNHcFvyO3mjsZ92lloHdp92y20brxDaG / 3K86 / 2H7Yb2jdsGt799ymZuoWWoepW9Pu7mjcc5sdfEfwG3J7cUfjntvsMHULrYN7blPzekfwG3K7uSP4Dbnd3NG4TzsLrUO7b7uF1o13CO3tfsX5F9sP + w2tG3Zt757b1EzdQuswdWva3R2Ne26zg + 8IfkNuL + 5o3HObHaZuoXVwz21qXu8IfkNuN3cEvyG3mzsa92lnoXVo92230LrxDqG93a84 / 2L7Yb + hdcOu7d1zm5qpW2gdpm5Nu7ujcc9tdvAdwW / I7cUdjXtus8PULbQO7rlNzesdwW / I7eaO4DfkdnNH4z7tLLQO7b7tFlo33iG0t / sV519sP + w3tG7Ytb17blMzdQutw9StaXd3NO65zQ6 + I / gNub24o3HPbXaYuoXWwT23qXm9I / gNud3cEfyG3G7uaNynnYXWod2 33ULrxjuE9na / 4vyL7Yf9htYNu7Z3z21qpm6hdZi6Ne3ujsY9t9nBdwS / IbcXdzTuuc0OU7fQOrjnNjWvdwS / IbebO4LfkNvNHY37tLPQOrT7tlto3XiH0N7uV5x / sf2w39C6Ydf27rlNzdQttA5Tt6bd3dG45zY7 + I7gN + T24o7GPbfZYeoWWgf33Kbm9Y7gN + R2c0fwG3K7uaNxn3YWWod233YLrRvvENrb / YrzL7Yf9htaN + za3j23qZm6hdZh6ta0uzsa99xmB98R / IbcXtzRuOc2O0zdQuvgntvUvN4R / Ibcbu4IfkNuN3c07tPOQuvQ7ttuoXXjHUJ7u19x / sX2w35D64Zd27vnNjVTt9A6TN2adndH457b7OA7gt + Q24s7GvfcZoepW2gd3HObmtc7gt + Q280dwW / I7eaOxn3aWWgd2n3bLbRuvENob / crzr / YfthvaN2wa3v33KZm6hZah6lb0 + 7uaNxzmx18R / AbcntxR + OE2 + wwdQutg3tuU / N6R / Abcru5I / gNud3c0bhPOwutQ7tvu4XWjXcI7e1 + xfkX2w / 7Da0bdm3vntvUTN1C6zB1a9rdHY17brOD7wh + Q24v7mjcc5sdpm6hdXDPbWpe7wh + Q243dwS / IbebOxr3aWehdWj3bbfQuvEOob3drzj / Yvthv6F1w67t3XObmqlbaB2mbk27u6Nxz2128B3Bb8jtxR2Ne26zw9QttA7uuU3N6x3Bb8jt5o7gN + R2c0fjPu0stA7tvu0WWjfeIbS3 + xXnX2w / 7De0bti1vXtuUzN1C63D1K1pd3c07rnNDr4j + A25vbijcc9tdpi6hdbBPbepeb0j + A253dwR / Ibcbu5o3Kedhdah3bfdQuvGO4T2dr / I / Ivth / 2G1g27tnfPbWqmbqF1mLo17e6Oxj232cF3BL8htxd3NO65zQ5Tt9A6uOc2Na93BL8ht5s7gt + Q280djfu0s9A6tPu2W2jdeIfQ3u5XnH + X / BD f0Lph1 / buuU3N1C20DlO3pt3d0bjnNjv4juA35PbijsY9t9lh6hZaB / fcpub1juA35HZzR / Abcru5o3GfdhZah3bfdgutG + 8Q2tv9ivMvth / 2G1o37NrePbepmbqF1mHq1rS7Oxr33GYH3xH8htxe3NG45zY7TN1C6 + Ce29S83hH8htxu7gh + Q243dzTu085C69Du226hdeMdQnu7X3H + xfbDfkPrhl3bu + c2NVO30DpM3Zp2d0fjntvs4DuC35Dbizsa99xmh6lbaB3cc5ua1zuC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fkNuL + 5o3HObHaZuoXVwz21qXu8IfkNuN3cEvyG3mzsa92lnoXVo92230LrxDqG93a84 / 2L7Yb + hdcOu7d1zm5qpW2gdpm5Nu7ujcc9tdvAdwW / I7cUdjXtus8PULbQO7rlNzesdwW / I7eaO4DfkdnNH4z7tLLQO7b7tFlo33iG0t / sV519sP + w3tG7Ytb17blMzdQutw9StaXd3NO65zQ6 + I / gNub24o3HPbXaYuoXWwT23qXm9I / gNud3cEfyG3G7uaNynnYXWod233ULrxjuE9na / 4vyL7Yf9htYNu7Z3z21qpm6hdZi6Ne3ujsY9t9nBdwS / IbcXdzTuuc0OU7fQOrjnNjWvdwS / IbebO4LfkNvNHY37tLPQOrT7tlto3XiH0N7uN / X + F2B + XubWz + TmAAAAAElFTkSuQmCC

但是当我使用时:

WebClient webClient = new WebClient();
webClient.DownloadFile(remoteFileUrl, localFileName);

抛出异常:“无法识别uri前缀”

1 个答案:

答案 0 :(得分:1)

没有要下载的图像链接。它是图像的base64表示形式,因此图像被编码在字符串中并嵌入到文档中。 您可以获取字符串的base64表示形式,并将其转换为图像here。粘贴代码以供快速参考。

 public Image Base64ToImage(string base64String)
 {
    // Convert base 64 string to byte[]
    byte[] imageBytes = Convert.FromBase64String(base64String);
    // Convert byte[] to Image
    using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
    {
        Image image = Image.FromStream(ms, true);
        return image;
    }
 }